Hi Andreas,
Try something like this:
// get the root element of "myNewDocument" Element root = myNewDocument.getRootElement(); // detach it from that document root.detach(); // then add it to the first document myDocument.getRootElement().add(root);
Your "more info" element will be added after the "info" element.
Note that you can't just add Documents to Documents... that breaks the rules of xml. Your parse output gives you a Document, but then you want to work with the Nodes/Elements within.
Look through the javadocs for Document, Node, Element, etc. There are many, many ways of manipulating element trees in Dom4J.
Ben
Andreas Andersson wrote:
Hi!
How do I add a Document to an existing Document? Or merge two Documents.
Document myDocument = DocumentHelper.parseText("<root><node>info</node></root>");
Document myNewDocument = DocumentHelper.parseText("<node>more info</node>");
I want to have the both nodes in the first Document.
Thanks.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user