Mega Code Archive

 
Categories / VB.Net / XML
 

XPathNavigator Matches determines whether the current node matches the specified 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 nodes As XPathNodeIterator = navigator.SelectDescendants("book", "", False)                  Dim expr As XPathExpression = navigator.Compile("book[@genre='novel']")         While nodes.MoveNext()             Dim navigator2 As XPathNavigator = nodes.Current.Clone()             If navigator2.Matches(expr) Then                 navigator2.MoveToFirstChild()                 Console.WriteLine("Book title:  {0}", navigator2.Value)             End If         End While     End Sub End Class