#42260 [Opn->Bgs]: Append Child of another DomDocument Object

From: Date: Thu, 09 Aug 2007 18:58:53 +0000
Subject: #42260 [Opn->Bgs]: Append Child of another DomDocument Object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115916@lists.php.net to get a copy of this message
ID: 42260 Updated by: rrichards@php.net Reported By: patryk dot t dot moura at losango dot com dot br -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Windows XP PHP Version: 5.2.4RC1 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 Read the error message. Previous Comments: ------------------------------------------------------------------------ [2007-08-09 18:38:19] patryk dot t dot moura at losango dot com dot br Description: ------------ I've got two DOMDocument Objects, so, i just wish to insert some node from the second object to a node of the first object... Reproduce code: --------------- $obj1 = new DOMDocument(); $obj2 = new DOMDocument(); $obj1->preserveWhiteSpace = false; $obj2->preserveWhiteSpace = false; $obj1->load("C:\\default.xml"); $obj2->load("C:\\second.xml"); If I do: $obj1->documentElement->getElementsByTagName("BODY")->item(0)->appendChild( $obj2->documentElement->getElementsByTagName("myNode")->item(0) ); Or $obj1->documentElement->getElementsByTagName("BODY")->item(0)->appendChild( $obj2->createElement("myNode") ); Expected result: ---------------- Expected to insert the node "myNode" of the second xml object at the "BODY" node of the first xml object... but like that, it doesn't work... =/ p.s.: the xml files are okay!!! just to you guys know!!! Actual result: -------------- I just get an exception that says that I can't add an DomElement with appendChild() function !!! O.o but if I do: $obj1->documentElement->getElementsByTagName("BODY")->item(0)->appendChild( $obj1->createElement("myNode") ); or $obj1->documentElement->getElementsByTagName("BODY")->item(0)->appendChild( $obj1->documentElement->getElementsByTagName("HEAD")->item(0) ); works perfectly! i just don't know what to do... honestly!!! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42260&edit=1

« previous php.bugs (#115916) next »