Hi
 
That is what the cockbook tells me to do, but the result is that root element from doc1 is placed in the root element of doc2. I just want the contents of doc1 root element to be placed in the root element of doc2.
 
The natural thing would then be to make a loop retriving each Node in the root element and adding them one by one in doc2 but how do I get a list that can be changed (when a detach is done the element is removed from the list ...) without throwing a ConcurrentModificationException...?
 
/Christian
-----Ursprungligt meddelande-----
Från: Benjamin Kopic [mailto:[EMAIL PROTECTED]
Skickat: den 14 oktober 2003 00:00
Till: Christian Holmqvist, IT, Posten
Ämne: Re: [dom4j-user] Moving elements from one document to another

have you tried detaching the root first from the first document before adding it to the second one? i.e.

Element rootDoc1 = doc1.getRootElement();
doc2.setRootElement(rootDoc1.detach());

If the second document has the root already set you may have to detach it first; e.g.
doc2.getRootElement().detach()

Best regards

Ben

On Mon, 2003-10-13 at 15:28, Christian Holmqvist, IT, Posten wrote:
Hi

Is there a easy way to move all element in the root element of one document to the root element in another document. I.e. merge two document?

I been trying different ways but keep on running into either IllegalAddException or ConcurrentModificationException :-/

Thank you for your time and effort!

/Christian
-- 
benjamin kopic
m: +44 (0)780 154 7643
t: +44 (0)20 7794 3090
e: [EMAIL PROTECTED]
w: http://www.panContext.com/

Reply via email to