php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42260 Append Child of another DomDocument Object
Submitted: 2007-08-09 18:38 UTC Modified: 2007-08-09 18:58 UTC
From: patryk dot t dot moura at losango dot com dot br Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.4RC1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: patryk dot t dot moura at losango dot com dot br
New email:
PHP Version: OS:

 

 [2007-08-09 18:38 UTC] 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!!!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-09 18:58 UTC] rrichards@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC