I have a problem with aliasing in XStream.
I’ve got a set of String items that I would like to serialize to XML like this:
<types>
<type>abc</type>
<type>def</type>
</types>
However, I can’t seem to find a good way to solve this. I’ve tried a list of strings, but then I end up with
<types>
<string>abc</string>
<string>def</string>
</types>
I’ve also tried putting the String in a simple class, but then I get
<types>
<type>
<aType>abc</aType>
</type>
</types>
where <type> is the alias of the custom class, and aType is the attribute in the class, i.e I get one level too much using this approach. How would I go about eliminating the extra level or simply substituting the <string> with a custom tag name?
You will need to alias both the
Listand the items in the list.Will result in