I am trying to parse a page which updates internal contents through javascript. When I look at the html through Firebug, it lookes like below:
<div id="productinfo">
<h2>
<span id="productname">Computer</span>
</h2>
<span id="servieidLabel" style=""> Service ID: </span>
<span id="snLabel" style="display: none"> Serial Number: </span>
<span id="servidno">12345ABCD</span>
However, when I right click the page and see the source, below is the structure of html:
<div id="productinfo">
<h2><span id="productname"></span></h2>
<span id="serviceidLabel" style="display: none">
Service ID:
</span>
<span id="snLabel" style="display: none">
Serial Number:
</span>
<span id="servidno"></span><br>
javascript:
warrantyPage.warrantycheck.displayProductInfo('Computer', true,'12345ABCD', false, '');
I am trying to parse and get the output like Service ID: 12345ABCD. Pls help me how to go about it. I have tried below code without any result because obviously service id number is not part of html but inserted by javascript
$servid = $xpath->query("//span[@id='servidno']");
foreach ($servid as $entry) {
echo "Service Id No:" ,$entry->nodeValue."<br />";
}
if javascript populating function always have the same parameters order, you can try to parse it:
the result will be an array:
The another method without regex:
the $args will become an array: