From: bobsledbob at yahoo dot com
Operating system: Linux
PHP version: 4.3.0
PHP Bug Type: DOM XML related
Bug description: append_child does not unlink node
Quoth the manual:
(PHP >= 4.3) The new child newnode is first unlinked from its existing
context, if it already existed in a document. Therefore the node is moved
and not copies anymore. This is the behaviour according to the W3C
specifications. If you want to duplicate large parts of a xml document,
use DomNode->clone_node() before appending.
It seems that the appended node is not unlinked in 4.3.0 as the manual
suggests? Here's my test script:
$xml = "<?xml version=\"1.0\" ?>";
$xml .= "<root>";
$xml .= "<node1 />";
$xml .= "<node2 />";
$xml .= "</root>";
$dom =& domxml_open_mem($xml);
$root =& $dom->document_element();
$nodeArray =& $root->child_nodes();
$node1 =& $nodeArray[0];
$node2 =& $nodeArray[1];
$node1->append_child($node2);
echo str_replace(" ", " ", str_replace("\n", "<br>\n",
htmlentities($dom->dump_mem(1))));
echo "Php Version: " . phpversion() . "<br>\n";
And here's my results:
<?xml version="1.0" ?>
<root>
<node1>
<node2/>
</node1>
<node2/>
</root>
Php Version: 4.3.0
Thanks.
Adam
--
Edit bug report at http://bugs.php.net/?id=22530&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22530&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22530&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22530&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22530&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22530&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22530&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22530&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22530&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22530&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22530&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22530&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22530&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22530&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22530&r=gnused