Hi,
i am currently making a class to handle xml files but my class will have a lot of child and i dont know if the way i keep the parent in the child node will be a copy of it or a pointer to it....
thx for taking time to answer.
private class XmlSubNode
{
List<XmlSubNode> m_lxsnMainList;
XmlNode m_MainNode;
XmlSubNode m_xsnParent;
string m_sName;
public XmlSubNode(XmlNode xnXmlNode) : this(xnXmlNode,null){}
public XmlSubNode(XmlNode xnXmlNode,XmlSubNode Parent)
{
this.m_MainNode = xnXmlNode;
this.m_sName = xnXmlNode.Name;
this.m_xsnParent = Parent;
if (this.m_MainNode.HasChildNodes)
{
foreach (XmlNode xNode in this.m_MainNode.ChildNodes)
{
XmlSubNode SubNode = new XmlSubNode(xNode,this);
this.m_lxsnMainList.Add(SubNode);
}
}
}
public XmlSubNode ParentNode
{
get { return this.m_xsnParent; }
}
public List<XmlSubNode> ChildNodes
{
get { return m_lxsnMainList; }
}
public bool HasParent
{
get
{
if (this.ParentNode == null) return false;
else return true;
}
}
public bool HasChildNodes
{
get { return (m_lxsnMainList.Count > 0); }
}
public string Name
{
get { return m_sName; }
}
}
}