I want to create one XML file from one list of objects. Objects are having some attributes, so the tags will be the attribute names and the respective data will be inside the tag.
This is example:
I have one List myEquipmentList, that contains 100 objects of the class Equipment. Now, the attributes in the class of Equipment are id, name, size, measures, unit_of_measure etc.
Now I want to create XML which will be something like this.
<Equipment id=1>``
<name>Ruler</name>
<size>1000</size>
<measures>length</measures>
<unit_of_measure>meter</unit_of_measure>
</Equipment>
Any ideas?
you can create a class with the list of objects, then serialise the list to xml and finally deserialise xml to a list.
Please see this link – Very useful:
How to convert List of Object to XML doc using XStream