Hi, I have a XML doc with parent/child references that I want to deserialize into .NET objects but am unable to do so. Below is the XML snippet:
<family>
<parents>
<parent id="1" name="Sam" />
<parent id="2" name="Beth" />
<parent id="3" name="Harry" />
</parents>
<children>
<child id="100" name="Tom">
<parent id="1">
</child>
<child id="200" name="Chris">
<parent id="2">
</child>
</children>
</family>
I want to be able to deserialize all the parent tags into the Parents collection using a .NET class as such.
class Child
{
string Name;
List<Parent> Parents;
}
class Parent
{
string Name;
int Id;
}
Any ideas? I tried Deserialize
method on the XmlSerializer
class but it only picks up the id attribute but does not relate it back to the parents node collection. Any help is appreciated. Thanks!