Mega Code Archive

 
Categories / VB.Net / XML
 

XPathNavigator Select (XPathExpression)

Imports System Imports System.Xml Imports System.Xml.XPath Public Class MainClass     Public Shared Sub Main()         Dim document As XPathDocument = New XPathDocument("books.xml")         Dim navigator As XPathNavigator = document.CreateNavigator()                  Dim query As XPathExpression = navigator.Compile("/bookstore/book")         Dim nodes As XPathNodeIterator = navigator.Select(query)         Dim nodesNavigator As XPathNavigator = nodes.Current                  Dim nodesText As XPathNodeIterator = nodesNavigator.SelectDescendants(XPathNodeType.Text, False)                  While nodesText.MoveNext()             Console.WriteLine(nodesText.Current.Value)         End While     End Sub End Class