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;
			
			
while(ti.hasNext())
{
     obj = ti.next();
     root = (Element)obj.getDocument();
}


doc.setRootElement(root);

[/code]

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();
   root.addContent(newElem);

Hope this helps.

Many thanks. The detach method works.