Problem with Xpath PHP
Posted
by user294597
on Stack Overflow
See other posts from Stack Overflow
or by user294597
Published on 2010-03-16T09:32:29Z
Indexed on
2010/03/16
9:36 UTC
Read the original article
Hit count: 245
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
© Stack Overflow or respective owner