#42260 [NEW]: Append Child of another DomDocument Object
| From: | patryk dot t dot moura at losango dot com dot br | Date: | Thu, 09 Aug 2007 18:38:19 +0000 |
| Subject: | #42260 [NEW]: Append Child of another DomDocument Object | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-115915@lists.php.net to get a copy of this message | ||
From: patryk dot t dot moura at losango dot com dot br
Operating system: Windows XP
PHP version: 5.2.4RC1
PHP Bug Type: DOM XML related
Bug description: Append Child of another DomDocument Object
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 bug report at http://bugs.php.net/?id=42260&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42260&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42260&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42260&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42260&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42260&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42260&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42260&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42260&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42260&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42260&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42260&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42260&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42260&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42260&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42260&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42260&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42260&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42260&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42260&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42260&r=mysqlcfg