XML : Jaxb xml Map as list elements

I am having trouble creating Java classes for the following XML:

  <Users>      <User id="1">          <Name>Test</Name>      </User>      <User id="2">          <Name>Test2</Name>      </User>  </Users>    

I am using Jaxb (javax.xml) with a Users class containing a User object. In this example User contains Id and Name, where Id is an attribute to the User element and Id is an element in User.

I have looked on some examples but all the examples and guides are focusing on having a root element surrounding Users (see below).

  <Database>          <Users>          <User id="1">              <Name>Test</Name>          </User>          <User id="2">              <Name>Test2</Name>          </User>      </Users>  </Database>    

Is it possible to remove the root element Database and just have Users with many User elements inside?

No comments:

Post a Comment