#40508 [NEW]: Namespace xpath doesn't work for nested elements
| From: | vrana@php.net | Date: | Fri, 16 Feb 2007 13:21:46 +0000 |
| Subject: | #40508 [NEW]: Namespace xpath doesn't work for nested elements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-109030@lists.php.net to get a copy of this message | ||
From: vrana@php.net
Operating system: Windows
PHP version: 5.2.1
PHP Bug Type: SimpleXML related
Bug description: Namespace xpath doesn't work for nested elements
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 bug report at http://bugs.php.net/?id=40508&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40508&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40508&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40508&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40508&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40508&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40508&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40508&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40508&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40508&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40508&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40508&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40508&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40508&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40508&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40508&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40508&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40508&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40508&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40508&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40508&r=mysqlcfg