|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-09 18:58 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 19:00:02 2025 UTC |
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!!!