(no subject)

[email protected]
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
hi all,
i would like to add the content of a document's root element to the root 
element of another document. here is my attempt:

> 			// create the document
> 			SAXBuilder builder = new SAXBuilder();
> 			Document doc1 = builder.build(new StringReader 
> ("<elem>test<e2></e2><t/></elem>"));
>  
> 			// get content of root element
> 			List content = doc1.getRootElement().getContent();
>  
> 			// detach: --> same exception with or without this
> 			for(int i=0;i<=content.size();i++){
> 				Content next = (Content)content.get(i);
> 				next.detach();
> 			}
>  
> 			// create 2nd document with root element
> 			Document doc2 = new Document();
> 			doc2.setRootElement(new Element("root2"));
>  
> 			// add content to new root: Exception here
> 			doc2.getRootElement().setContent(content); 
 
Exception in thread "main" org.jdom.IllegalAddException: The Content 
already has an existing parent "elem"
 
detaching all Contents in the list does not seem to have an effect.

how can i solve this?
thank you!

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.