XML without root element in JAXB

I was wondering if there is a way to create an object so that the list of such an object does not need a root element. For example, if I wanted to create XML, for example

<Dogs> <Dog>A</Dog> <Dog>B</Dog> <Dog>C</Dog> </Dogs> 

I could have a class Dogs , which will be the root element and has a List<Dog> . Suppose I want to get rid of the encapsulating <Dogs> element. To make the list of dogs look like

 <Dog>A</Dog> <Dog>B</Dog> <Dog>C</Dog> 

How should I build my classes?

+4
source share
1 answer

In XML, this is not possible. The specification http://www.w3.org/TR/xml/#NT-document clearly states that the document has one root element.

So your second XML is not an XML document, but a combination of three XML documents. But parsers are usually not prepared for such input.

+2
source

All Articles