Reputation: 799
Sometimes I would like to generate the XML document like this:
<?xml version="1.0" encoding="utf-8"?>
<properties>
</properties>
<context>
</context>
Do not with root elment, not like this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<properties>
</properties>
<context>
</context>
</root>
Here is my Class:
//@XmlRootElement(name="root")
public class WithoutRootElement {
private String properties;
Private String context;
@XmlElement(name="properties")
public String getProperties() {...}
@XmlElement(name="context")
public String getContext() {...}
}
How to do this?
Upvotes: 0
Views: 480
Reputation: 3245
According to the Well-formedness of an XML:
There is a single "root" element that contains all the other elements.
Upvotes: 0
Reputation:
What you want is not valid XML. So neither JAXB nor any other technologie can produce a "document" like this.
Upvotes: 2