joining documents into one big document

I would like to put the result documents of my query in one document with root element “Trefferliste.”

The line

root = (Element)obj.getDocument();

is not working. How can I integrate the documents?

TResponse tresp=sendQuery(query, tacc);
Document doc = new Document();
Element root=new Element("TrefferListe");		
TXMLObjectIterator ti = tresp.getXMLObjectIterator() ;
TXMLObject obj;
     obj =;
     root = (Element)obj.getDocument();



I assuming you are using JDOM. Firstly you should use getElement() rather than getDocument(). Then within your iterator body instead of

   root = (Element)obj.getDocument();

code something like:

   newElem = (Element)obj.getElement();
   newElem = (Element)newElem.detach();

Hope this helps.

Many thanks. The detach method works.