ID: 41663 Updated by: [EMAIL PROTECTED] Reported By: kenashkov at gmail dot com -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Fedora Core 4 PHP Version: 5.2.3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The results are exactly what you requested based on your XPath expression. You used absolute paths not relative: http://www.w3.org/TR/xpath#location-paths Previous Comments: ------------------------------------------------------------------------ [2007-06-12 08:10:55] kenashkov at gmail dot com Description: ------------ The evaluation of the Xpath expressions is not relative to the node against which they are called ([2]). Worse - even after cloning a node from the structure and evaluating the xpath, the xpath expression seems to be evaluated against the original structure, not against the new one (which is a copy of a part of the original) ([3]). This was discussed in the dev-list here: http://marc.info/?l=php-dev&m=118001203709813&w=2 If this is not a bug, but expected result, I think a note addressing this behaviour must be added in the docs. Reproduce code: --------------- $str = '<rootnode><level1_node1><level2_node1></level2_node1></level1_node1><level1_node2></level1_node2></rootnode>'; $x = new SimpleXMLElement($str); //[1] $r1 = $x->xpath('/*'); print $r1[0]->getName().' '; //[2] $r2 = $x->level1_node1[0]->xpath('/*'); print $r2[0]->getName().' '; //[3] $z = clone $x->level1_node1[0]; $r3 = $z->xpath('/*'); print $r3[0]->getName().' '; Expected result: ---------------- rootnode level1_node1 level1_node1 Actual result: -------------- rootnode rootnode rootnode ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41663&edit=1