Select all the ancestor nodes of the title node
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim document As XPathDocument = New XPathDocument("domainBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToChild("bookstore", "http://www.domain.com/books")
navigator.MoveToChild("book", "http://www.domain.com/books")
navigator.MoveToChild("title", "http://www.domain.com/books")
Dim bookAncestors As XPathNodeIterator = navigator.SelectAncestors("", "http://www.domain.com/books", False)
While bookAncestors.MoveNext()
Console.WriteLine(bookAncestors.Current.Name)
End While
End Sub
End Class
Related examples in the same category