ID: 27709 Updated by: [EMAIL PROTECTED] Reported By: fjortiz at comunet dot es -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Windows 2000 Server PHP Version: 5.0.0RC1 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is an XPath limitation. You need to use an expression like //*[local-name() = 'a'] or dont use default namespaces. Previous Comments: ------------------------------------------------------------------------ [2004-03-26 04:51:30] fjortiz at comunet dot es Description: ------------ Hi, this example works with SimpleXML xpath: $string = <<<XML <?xml version="1.0" encoding ="UTF-8" ?> <a xmlns:ns="urn:1"> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); $res = $xml->xpath('//a'); // returns array(1) But if we don't use a namespace prefix (default namespace), xpath, returns an empty array, array(0), for any xpath search: $string = <<<XML <?xml version="1.0" encoding ="UTF-8" ?> <a xmlns="urn:1"> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); $res = $xml->xpath('//a'); // returns array(0) This is a simple example, I found the problem with a bigger XML file (a WSDL file). This WSDL has 5 namespaces defined, and no problem at all with SimpleXML, as long as you don't define a default namespace... Thanks for your attention ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27709&edit=1
