any node above the current node in an hierarchical tree example the parent,grandparent,great-grandparent or the rot node are all ancestors of anode within an xml
How might I get the grand parent and great grand parent of a current node xml.
I’m using VB.Net in an ASP.NET application.
thank wow answers are beautiful
can i have something like XmlNode greatGrandParent = myNode.ParentNode.ParentNode.ParentNode.lastchild.lastchild
Using the System.Xml the XmlNode has a ParentNode property so you could use that to traverse up the tree.
Using the System.Xml.XPath the XPathNavigator has a MoveToParent method.
Using System.Xml.Linq the XNode class has an Ancestors method which can be a bit neater:-