You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Steve Chervitz <sa...@neomorphic.com> on 2000/05/13 01:56:40 UTC

Changing owner document

I recently started using Xerces-J coming from XML4J and have run into
the following snag. I want to take a node from one document and add it
to a node on a different document. Using XML4J, this is what I would
do:

    // aDoc and anotherDoc are different DocumentImpl objects

    Node foo = aDoc.removeChild(
                        aDoc.getElementsByTagName("foo").item(0));
        
    Node bar = anotherDoc.getElementsByTagName("bar").item(0);

    bar.appendChild(foo);

When I do this I get the following error:

  org.apache.xerces.dom.DOMExceptionImpl: DOM005 Wrong document

How do I change the owner document for a node? 

Thanks,
Steve