Page 1 of 1

Copy XML nodes with DOM

Posted: Sun Jun 18, 2006 7:06 am
by tolano
Hi, I'm a PHP 5 user, I've been using the DOM for a while, but now, I can't solve a problem.
The best way to explain is witn an example:
I have 2 XML documents:
Doc 1:

Code: Select all

<root>
    <one />
    <two>
         Hello
            <three>World</three>
    </two>
</root>
Doc 2:

Code: Select all

<whatever>
   <node />
</whatever>
I want the content of <two> inside <node>, but I don't want to copy the <two> tag, I want this:

Code: Select all

<whatever>
   <node>
      Hello
            <three>World</three>
    </node>
</whatever>
So, I can't do it with ImportNode and AppendChild. I have no idea how to do it.
Can someone help me please?
Thank you very much.