|
Node doc1OwnedNode = doc.importNode(doc2.getDocumentElement()); doc.appendChild(doc1OwnedNode); But read DOM specs first that Joseph Kesselman pointed out. Lingzhi Zhang wrote: Hi, I am experimenting how to append a piece of xml into an existing xml using DOM. My code is like,DocumentBuilder parser = factory.newDocumentBuilder(); InputSource in = new InputSource(xmlFile); Document doc = parser.parse(in); I got anothe Document doc2 in the same way. The I tried 1. doc.appendChild(doc2); 2. doc.appendChild(doc2.getDocumentElement()); 3. doc.getDocumentElement().appendChild(doc2.getDocumentElement()); 4. aNode.appendChild(doc2); //aNode is a node in doc But none of the above worked, the code always throws the exception: "org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it." In the api it says, "WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node. " However, I still don't understand wha this exactly means. What is wrong with the appending in my code? Thanks. Stephen --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --
Maksym
Kovalenko |
- Problems with big files Alexis
- RE: Problems with big files Gary Gregory
- Re: Problems with big files Alexis
- RE: Problems with big files Charles Hudak
- Re: Problems with big files Dave Flanagan
- Re: Problems with big files Alexis
- appendNode() in DOM Lingzhi Zhang
- Re: appendNode() in DOM Joseph Kesselman
- Re: appendNode() in DOM Maksym Kovalenko
- Re: appendNode() in DOM Lingzhi Zhang
- Re: appendNode() in DOM Jacob Kjome
- Re: appendNode() in DOM Lingzhi Zhang
- Re: appendNode() in DOM Mike Rawlins
- Re: appendNode() in DOM Mike Rawlins
