[jdom-interest] IllegalAddException: Cannot add a second root element, only one is allowed

Jason Hunter jhunter at xquery.com
Sat Aug 13 11:34:08 PDT 2005


It's not well-formed XML to have more that one root node, so JDOM 
doesn't allow it.  If you wanted to create a file containing this "fake 
XML" you could just serialize multiple JDOM documents out the same 
stream, one after the other.  You won't have much luck getting an XML 
parser to read it back in, however.

-jh-

Mert Nuhoglu wrote:

> Hi,
> 
> Document element doesn't allow to have more than one root. But I need
> to generate an xml document that must have more than one root. What do
> you suggest me to do?
> 
> A part of the document that I need to produce is here:
> 
> <!DOCTYPE RAVE><RAVE version="3.16.4">
> 
> <Institution>My institution</Institution>
> 
> <Comments>My comments</Comments>
> 
> Maybe I can produce the document in JDom where all the elements are
> wrapped under a root element. Then I can remove this wrapper tag out
> of the JDom.
> 
> Thanks...
> 


More information about the jdom-interest mailing list