Re: SimpleXML and xpath woes

From: Date: Thu, 17 Mar 2005 12:47:41 +0000
Subject: Re: SimpleXML and xpath woes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-210968@lists.php.net to get a copy of this message
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

« previous php.general (#210968) next »