System.Xml.XPathNodePointer.GetRoot C# (CSharp) Method

GetRoot() private static method

private static GetRoot ( XmlNode node, int &depth ) : XmlNode
node XmlNode
depth int
return XmlNode
        private static XmlNode GetRoot(XmlNode node, ref int depth)
        {
            depth = 0;
            XmlNode curNode = node;
            XmlNode parent = ((curNode.NodeType == XmlNodeType.Attribute) ? (((XmlAttribute)curNode).OwnerElement) : (curNode.ParentNode));
            for (; parent != null; depth++)
            {
                curNode = parent;
                parent = curNode.ParentNode; // no need to check for attribute since navigator can't be built on its children or navigate to its children 
            }
            return curNode;
        }