Re: SimpleXML and xpath woes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rob Richards kindly sent me the following response via email - posting it here as he's not subscribed.


You need to register a namespace for XPath since there's a default namesapce.


$xml = simplexml_load_file('test.xml');
/* Register arbitrary namesapce prefix for xpath*/
$xml->registerXPathNamespace('p', 'http://webservices.amazon.com/AWSECommerceService/2005-02-23');
$query = '//p:ItemLookupResponse';
$result = $xml->xpath($query);
var_dump($result);

Just to add to this: the registerXPathNamespace method is only present in CVS/snapshot builds and is scheduled for the 5.1 release.

Cheers,

Simon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux