<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.XPath" %>
<script runat="server">
sub Page_Load(Sender as object, e as EventArgs)
Dim objReader as New XmlTextReader(Server.MapPath("Data.xml"))
Dim objDoc as XPathDocument = new XPathDocument(objReader)
Dim objNav as XPathNavigator = objDoc.CreateNavigator()
DisplayNode(objNav)
end sub
sub DisplayNode(objNav as XPathNavigator)
If objNav.HasChildren then
objNav.MoveToFirstChild()
Format(objNav)
DisplayNode(objNav)
objNav.MoveToParent()
End If
While objNav.MoveToNext()
Format(objNav)
DisplayNode(objNav)
end While
end sub
Private Sub Format(objNav As XPathNavigator)
If Not objNav.HasChildren then
if objNav.NodeType <> XmlNodeType.Text then
Response.Write("<<b>" & _
objNav.Name & "</b>>")
end if
Response.Write(" - " & objNav.Value & _
"<br>" & vbCrLf)
Else
Dim i As Integer
Response.Write("<<b>" & objNav.Name & _
"</b>>" & vbCrLf)
If objNav.HasAttributes then
Response.Write("<br>Attributes of <" & _
objNav.Name & "><br>" & vbCrLf)
End If
while objNav.MoveToNextAttribute()
Response.Write("<<b>" & objNav.Name & "</b>> " & objNav.Value & " ")
end while
Response.Write("<br>" & vbCrLf)
End If
end sub
</script>
<html><body>
</body></html>
|