Nodes belong to a document, and therefore cannot be appended to another
document.  They can be imported from one document to another, however; check
out DOMDocument::importNode().

-----Original Message-----
From: Williams, Rodger [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 19, 2003 7:55 AM
To: [EMAIL PROTECTED]
Subject: appendChild


I have two DOMDocument classes, doc1 and doc2 with their respective root
nodes node1 and node2
How do I append doc2, with parent node, and all its children nodes and
attributes, etc etc into doc1 as a child so that doc1 looks exactly the
same, only as a child of doc1.

I tried appending doc2 to the root node of doc1. I got an unhandled
exception.

        node1 = doc1.getDocumentElement();
        node1.appendChild(doc2)

I tried appending the rootnode of doc2 to the root node of doc1. Again, I
got an unhandled exception.
        
        node1 = doc1.getDocumentElement();
        node2 = doc2.getDocumentElement();
        node1.appendChild(node2)

Essentially what I want to do is this.

I want to take two xml files:

        doc1 :  <reply>
                        <error>
                                blah blah blah
                        </error>
                </reply>

        doc2 :  <request request_type="blahblah">
                        <r1>
                                <r11>
                                <r/11>
                                <r12>
                                <r/12>
                        </r1>
                        <r2>
                                <r21>
                                <r/21>
                                <r22>
                                <r/22>

                        </r2>
                </request>

and create a third:

        doc3:  <reply>
                        <error>
                                blah blah blah
                        </error>
                        <request request_type="blahblah">
                                <r1>
                                        <r11>
                                        <r/11>
                                        <r12>
                                        <r/12>
                                </r1>
                                <r2>
                                        <r21>
                                        <r/21>
                                        <r22>
                                        <r/22>
                                </r2>
                        </request>
                </reply>

        





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to