0

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; }
            }
        }
    }

Edited by madrang: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by madrang
0

after some little test it seam to be a fail as it only store a copy of the parent... i need to store a reference to the parent.... any idea how i can do this without using pointer or unsafe code ???

EDIT : sorry my test are maybe bad.... so does the code above will have a ref or a copy of it and if it is a copy, how i could store a ref to the parrent.

Edit 2 : solved by my self and a friend on msn, sorry for wasting your time.

thx to all who read this post....

Edited by madrang: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.