Possible Duplicate:
DOMElement cloning and appending: ‘Wrong Document Error’
I would like to copy all the child nodes of element foo in DOMDocument A into element bar in DOMDocument B. However, using appendChild to do so apparently throws a DOM_WRONG_DOCUMENT_ERR.
Is there a right way of doing this?
XML Document A
<foo>
    <child />
    <child />
    <child />
</foo>
XML Document B
<bar>
    <other-child />
    <other-child />
</bar>
Resulting DOMDocument:
<bar>
    <other-child />
    <other-child />
    <child />
    <child />
    <child />
</bar>
The elements should not be assumed to be empty, but are arbitrarily complex.