Posted by Simon Turvey on 03/17/05 14:47
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
[Back to original message]
|