lets say i have the following XML
<?xml version="1.0" encoding="utf-8"?>
<names>
<name first="John" last="Doe"/>
<name first="Jane" last="Doe"/>
...
</names>
This is my code:
final JAXBContext context = JAXBContext.newInstance(Names.class);
final Unmarshaller um = context.createUnmarshaller();
final InputStream in = new FileInputStream(file);
final Reader reader = new InputStreamReader(in, Charset.forName("UTF-8"));
final Names namesList = (Names) um.unmarshal(reader);
...
Now i could not find any documentation describing in which order these elements will be. In my application it is important that the order which is in my XML file will be the same in the java object. I tried to look it up in the source but it was very difficult to understand. I hope somebody can help me on this one. Thanks.
kuku
For elements that correspond to a List property the order in the List will match the order from the XML document.
For more information on JAXB and collection properties see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With