ID:               22530
 Updated by:       [EMAIL PROTECTED]
 Reported By:      bobsledbob at yahoo dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         DOM XML related
 Operating System: Linux
 PHP Version:      4.3.0
-Assigned To:      
+Assigned To:      chregu
 New Comment:

yep. wrong. it just unlinks the node, if it's a child of the parent
node ($node1 in your case). I'll fix that.

chregu


Previous Comments:
------------------------------------------------------------------------

[2003-03-04 00:53:02] bobsledbob at yahoo dot com

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(" ", "&nbsp;&nbsp;", 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 this bug report at http://bugs.php.net/?id=22530&edit=1

Reply via email to