From:             schalk at unf dot edu
Operating system: Mac OSX 10.4.8
PHP version:      5.2.1
PHP Bug Type:     DOM XML related
Bug description:  previousSibling not giving the correct element

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)

-- 
Edit bug report at http://bugs.php.net/?id=40500&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40500&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40500&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40500&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40500&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40500&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40500&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40500&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40500&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40500&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40500&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40500&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40500&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40500&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40500&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40500&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40500&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40500&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40500&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40500&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40500&r=mysqlcfg

Reply via email to