I have the following html and i am using php's DomDocument class to get the element with id 'nextPageBtn' next to the script tag. the problem is my query doesnot return anything (as if there is no element with the specified id). heres the html i am parsing.
<body>
<div style='float:left'><img src='../../../../includes/ph1.jpg'></div>
<label style='width: 476px; height: 40px; position: absolute;top:100px; left: 40px; z-index: 2; background-color: rgb(255, 255, 255);; background-color: transparent' >
<font size="4">1a. Nice to meet you!</font>
</label>
<img src='ENG_L1_C1_P0_1.jpg' style='width: 700px; height: 540px; position: absolute;top:140px; left: 40px; z-index: 1;' />
<script type='text/javascript'>
swfobject.registerObject('FlashID');
</script>
<input type="image" id="nextPageBtn" src="../../../../includes/ph4.gif" style="position: absolute; top: 40px; left: 795px; ">
</body>
and heres the php code to parse it.
$doc->loadHTMLFile($path);
$doc->encoding='UTF-8';
$x = new DOMXPath($doc);
$nextPage=$x->query("//*[@id='nextPageBtn']")->item(0);
if($nextPage)
{
echo 'found it..';
}
I think the line 'swfobject.registerObject('FlashID')' is generating some kind of error which is avoiding the element to be found?
$doc->encoding='UTF-8';looks superfluous to me.getElementByIdworks.