C# System.Xml.Serialization Self-nested elements
- by Jake
Hi, I am trying to deserialize
<graph>
<node>
<node>
<node></node>
</node>
</node>
<node>
<node>
<node></node>
</node>
</node>
</graph>
with
[XmlRoot("graph")]
class graph
{
List<node> _children = new List<node>();
[XmlElement("node")]
public Node[] node
{
get { return _children.ToArray(); }
set { foreach(node n in value) children.add(n) }
};
}
class node
{
List<node> _children = new List<node>();
[XmlElement("node")]
public Node[] node
{
get { return _children.ToArray(); }
set { foreach(node n in value) children.add(n) }
};
}
but it keeps saying object not created, null reference encountered when trying to set children nodes. What is wrong above?
Thanks in advance~