Bug #62260 [NEW]: XPath does not search correctly in nodes with text and other nodes
| From: | yajo dot sk8 at gmail dot com | Date: | Fri, 08 Jun 2012 07:34:19 +0000 |
| Subject: | Bug #62260 [NEW]: XPath does not search correctly in nodes with text and other nodes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-171129@lists.php.net to get a copy of this message | ||
From: yajo dot sk8 at gmail dot com
Operating system: Linux
PHP version: 5.3.13
Package: *XML functions
Bug Type: Bug
Bug description:XPath does not search correctly in nodes with text and other nodes
Description:
------------
When a node has inner nodes and you want to search into its text value,
only the first text node is selected.
This is wrong because, as http://www.w3.org/TR/xpath/#path-abbrev says:
> text() selects all text node children of the context node
Test script:
---------------
$xml = <<<END
<?xml version="1.0" encoding="UTF-8"?>
<root>
<first>
Hello
<second>
world
</second>
world
</first>
</root>
END;
$doc = DOMDocument::loadXML($xml);
$xpath = new DOMXPath($doc);
foreach ($xpath->query('//*[contains(text(), "world")]') as $node)
echo $node->nodeName . PHP_EOL;
Expected result:
----------------
first
second
Actual result:
--------------
second
--
Edit bug report at https://bugs.php.net/bug.php?id=62260&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62260&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62260&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62260&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62260&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62260&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62260&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62260&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62260&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62260&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62260&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62260&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62260&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62260&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62260&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62260&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62260&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62260&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62260&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62260&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62260&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62260&r=mysqlcfg