<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Untitled Page
File: Default.aspx.vb
Imports System.IO
Imports System.Xml
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 bookcount As Integer = 0
Dim settings As New XmlReaderSettings()
settings.IgnoreWhitespace = True
settings.IgnoreComments = True
Dim booksFile As String = _
Path.Combine(Request.PhysicalApplicationPath, "Data.xml")
Using reader As XmlReader = XmlReader.Create(booksFile, settings)
While (reader.Read())
If (reader.NodeType = XmlNodeType.Element _
And "book" = reader.LocalName) Then
bookcount += 1
End If
End While
End Using
Response.Write(String.Format("Found {0} books!", bookcount))
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