Edit report at http://bugs.php.net/bug.php?id=40508&edit=1
ID: 40508 Comment by: kkezmg at gmail dot com Reported by: vr...@php.net Summary: Namespace xpath doesn't work for nested elements Status: Bogus Type: Bug Package: SimpleXML related Operating System: Windows PHP Version: 5.2.1 Assigned To: helly New Comment: So, has this been fixed? Previous Comments: ------------------------------------------------------------------------ [2007-03-26 20:22:03] rricha...@php.net 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 XPath context is per SimpleXMLElement object, so although the register in nested element looks like it would work, that too uses different objects. Thanks for the report though as it did expose a bug with the node being used for the XPath context node though. ------------------------------------------------------------------------ [2007-02-16 13:21:46] vr...@php.net Description: ------------ Registering XPath namespace works only for XPath queries from root element. Reproduce code: --------------- $text = '<a xmlns="http://example.org"><b><c>test</c></b></a>'; $xml = simplexml_load_string($text); // register in root $xml->registerXPathNamespace("x", "http://example.org"); print_r($xml->b->xpath("x:c")); // register in nested element $xml->b->registerXPathNamespace("x", "http://example.org"); print_r($xml->b->xpath("x:c")); Expected result: ---------------- At least once: Array ( [0] => SimpleXMLElement Object ( [0] => test ) ) Actual result: -------------- Warning: SimpleXMLElement::xpath(): Undefined namespace prefix Warning: SimpleXMLElement::xpath(): Undefined namespace prefix ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=40508&edit=1