Bug #69712 [NEW]: XPath selecting namespaced nodes only matches every second one

From: Date: Wed, 27 May 2015 13:45:56 +0000
Subject: Bug #69712 [NEW]: XPath selecting namespaced nodes only matches every second one
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192916@lists.php.net to get a copy of this message
From: danielklein at airpost dot net Operating system: * PHP version: 5.6.9 Package: DOM XML related Bug Type: Bug Bug description:XPath selecting namespaced nodes only matches every second one Description: ------------ A simple XPath that matches namespaces should return all nodes, however, it only returns every second one. Using the below link I confirmed this issue for all versions of PHP 5.0.0 - 5.6.9 http://3v4l.org/4qZhu Test script: --------------- <?php $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadXML('<root xmlns:ns="foo" ns:id="1"> <one/> <two/> <three/> <four/> <five/> </root>'); $finder = new DOMXPath($doc); $nodes = $finder->query("//node()[namespace::ns]"); foreach ($nodes as $n) { var_dump($doc->saveXML($n)); } Expected result: ---------------- string(78) "<root xmlns:ns="foo" ns:id="1"> <one/> <two/> <three/> <four/> <five/> </root>" string(6) "<one/>" string(6) "<two/>" string(8) "<three/>" string(7) "<four/>" string(7) "<five/>" Actual result: -------------- string(78) "<root xmlns:ns="foo" ns:id="1"> <one/> <two/> <three/> <four/> <five/> </root>" string(6) "<two/>" string(7) "<four/>" -- Edit bug report at https://bugs.php.net/bug.php?id=69712&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69712&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69712&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69712&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69712&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69712&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69712&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69712&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69712&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69712&r=support Expected behavior: https://bugs.php.net/fix.php?id=69712&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69712&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69712&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69712&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69712&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69712&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69712&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69712&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69712&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69712&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69712&r=mysqlcfg

« previous php.bugs (#192916) next »