<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Untitled Page
File: Default.aspx.vb
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
Dim booksFile As String = Path.Combine(Request.PhysicalApplicationPath, _
"Data.xml")
Dim document As New XPathDocument(booksFile)
Dim nav As XPathNavigator = document.CreateNavigator()
Dim namespaceMgr As New XmlNamespaceManager(nav.NameTable)
namespaceMgr.AddNamespace("b", "http://example.books.com")
For Each node As XPathNavigator In nav.Select( _
"//b:book[not(b:price[. > 10.00])]/b:price", namespaceMgr)
Dim price As Decimal = _
CType(node.ValueAs(GetType(Decimal)), Decimal)
Response.Write(String.Format("Price is {0}
", _
price))
Next
End Sub
End Class
File: Data.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
publicationdate="1981"
ISBN="1-11111-11-0">
title 1
A
B
8
publicationdate="1999"
ISBN="0-222-22222-2">
title 2
C
D
11.99