Search code examples
javaxstream

Deserializing a legacy XML structure in xstream


I'm trying to deserialize an xml structure that looks like this:

<somecontainer>
    <key1>Value1</key1>
    <key1>Value2</key1>
    <key2>Value3</key2>
    <key2>Value4</key2>
</somecontainer>

I can basically choose what kind if element to deserialize to, maybe something like a List of Pair or something. The essence here is that the element names are the keys.

And no, I cannot change the xml structure. Anyone know how to do this with xstream ?


Solution

  • I have found that a custom serializer is needed for this case, no way around it.

    Similarly

    <node attr1="xxx">value1</node>
    

    also needs a custom serializer.