My XML looks like this:
<root>
<box id="1">
<code>xxx</code>
<thing name="a"/>
<thing name="b"/>
</box>
<box id="2">
<code>yyy</code>
<thing name="c"/>
<thing name="d"/>
</box>
</root>
How do I attribute these classes (see classes below) so that I can deserialize from the above xml?
class Root
{
List<Box> boxes;
}
class Box
{
int id;
string code;
List<Thing> things;
}
class Thing
{
string name;
}
The issue is that there is no xml container element in the incoming xml. there's no <boxes> element in a root, and no <things> element in a box. (the schema is already defined this way, it's not an option to change it. I just want to know how to deserialize from it when there is no container element)
How should I assign attributes to these classes for deserialization?
I have tried messing around with the XmlArray and XmlArrayItem attributes, but don't get it yet from the examples on the MSDN Library docs.