i'm trying to get some attributes for HTML tags in web page for example
<html>
<head>
<title>test page</title>
</head>
<body>
<div id="header" class="clearit" role="banner">
<div id="headerWrapper">
<ul id="primaryNav" role="navigation">
<li id="musicNav" class="navItem">
<a href="/music" class="nav-link">Music</a>
</li>
<li id="listenNav" class="navItem">
<a href="/listen" class="nav-link">Radio</a>
</li>
<li id="eventsNav" class="navItem">
<a href="/events" class="nav-link">Events</a>
</li>
<li id="chartsNav" class="navItem">
<a href="/charts" class="nav-link">Charts</a>
</li>
<li id="communityNav" class="navItem">
<a href="/community" class="nav-link">Community</a>
</li>
<li id="originalsNav" class="navItem">
<a href="http://originals.last.fm" class="nav-link">Originals</a>
</li>
</ul>
</div>
</div>
</body>
</html>
for example i need the actual Height and width for #headerWrapper and compare it with #musicNav in my PHP program , since php is server side i can't get these attribute so i'm thinking to append javascript code to calculate these attribute and store it in json file like this code
<script type="text/javascript">
document.ready(function() {
var JSONObject= {
"tagname":"headerWrapper",
"height":$("#headerWrapper").height(),
"width":$("#headerWrapper").width()
},
{
"tagname":"musicNav",
"height":$("#musicNav").height(),
"width":$("#musicNav").width()
}
});
});
</script>
then read it by php file contain my algorithm witch extract visual features from webpages.
but my problem is i need to render the webpage with appended javascript using some browser or rendering engine in PHP or java ... so dose any one have some thing like that? is my method right or there is better solution?