|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-02-15 19:41 UTC] tony2001@php.net
[2007-02-15 19:53 UTC] schalk at unf dot edu
[2007-02-15 19:57 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 22:00:02 2025 UTC |
Description: ------------ When I use previousSibling to get values of elements at the same level in the tree it does not work as expected. Seems to need 2x the previousSibling calls to get to the right node. Seems to be adding in extra return characters (see actual result). Note: echo "Found ".$entry->previousSibling->previousSibling->previousSibling->previousSibling->nodeValue." by ".$entry->previousSibling->previousSibling->nodeValue."<br>\n"; produces the correct result! Reproduce code: --------------- <?php $xml= new DOMDocument(); $xml->load('http://fad.coas.unf.edu/animl/jcamp/xpathtest.xml'); $xpath = new DOMXPath($xml); $entries = $xpath->query('/book/chapter/para/informaltable/tgroup/tbody/row/entry[. = "en"]'); foreach ($entries as $entry) { echo "Found ".$entry->previousSibling->previousSibling->nodeValue." by ".$entry->previousSibling->nodeValue."<br>\n"; } Expected result: ---------------- Found The Grapes of Wrath by John Steinbeck<br> Found The Pearl by John Steinbeck<br> (returned web page source code) Actual result: -------------- Found John Steinbeck by <br> Found John Steinbeck by <br> (returned web page source code)