Problem with Xpath PHP
- by user294597
Im tring to access some links through Google using xpath. The below does works fine and all the links are shown.
$query = $xpath->evaluate("/html/body//a");
for ($x=0 ; $x < $query -> length; $x++)
{
$href=$query->item($x);
$url=$href->getAttribute('href');
echo $url."<br>";
}
But when i try the below xpath nothing is shown..Im sure that the xpath is correct coz its evaluated and the result is shown in xpather..
/html/body[@id='gsr']/div[@id='cnt']/div[@id='res']/div[1]/ol/li/div//cite
for ($x=0 ; $x < $query -> length; $x++)
{
$href=$query->item($x);
$url=$href->getAttribute('cite');
echo $url."<br>";
}
can some one please tell me what i am doin wrong? any help will be much appreciated