xml
xml copied to clipboard
Preserve order while deserializing
Assume the following xml:
<parent>
<objA/>
<objB/>
<objA/>
</parent>
How can I deserialize this in a fashion that preserves the order 'objA' 'objB' 'objA'?
Deserializing into a Vec<ObjA>
and a Vec<ObjB>
would not preserve the information that the single ObjB
was deserialized between the other two.
I guess in this case an enum like enum Obj { ObjA, ObjB}
, and then a Vec<Obj>
would make sense, but from what I saw in the tests this only works when the xml looks like <obj xsi:type="ObjA">
etc.
Is there a good way to do this (without deserializing the whole parent
manually)?