|
xxx
Using XPathNavigator objects to Read XML Data
by Charles Carroll
Here is code to read an XML File with an XPath Navigator objects
filename=/experiments/booksfave/xpathnavigator.aspx
<%@trace="true" debug="true" %>
<%@ Import Namespace="System.XML.Xpath"%>
<script language="VB" runat="server">
Sub Page_Load(S As Object, E As EventArgs)
trace.tracemode=TraceMode.SortByTime
DIM xpthdoc1 as XPathDocument
DIM xpthnv1 as XPathNavigator
'DIM xpthitr as XpathNodeIterator
TRY
xpthdoc1=new XpathDocument(server.mappath("/experiments/data/favebooks.xml"))
xpthnv1=xpthdoc1.CreateNavigator()
xpthnv1.MoveToRoot()
trace.write("MovetoRoot xpthnv1.name=" & xpthnv1.name)
xpthnv1.MoveToFirstChild()
trace.write("MovetoFirstChild xpthnv1.name=" & xpthnv1.name)
xpthnv1.MoveToFirstChild()
trace.write("MovetoFirstChild xpthnv1.name=" & xpthnv1.name)
DO WHILE xpthnv1.movetoFirstChild()
trace.write("MovetoFirstChild xpthnv1.name=" & xpthnv1.name)
DO WHILE xpthnv1.moveToNext()
trace.write("MovetoNext xpthnv1.name=" & xpthnv1.name)
trace.write("MovetoNext xpthnv1.value=" & xpthnv1.value)
LOOP
LOOP
CATCH ex1 as exception
FINALLY
'Xmltr1.Close()
END TRY
End Sub
</script>
<html><head>
<title>XML Demo</title>
</head>
<body bgcolor="#FFFFFF">
<form runat="server">
<ASP:placeholder id="plcErr" runat="server" />
See The Trace For More Details
<AsP:Table id="tblXMlDetails" runat="server" />
<ASP:placeholder id="plcEndofPage" runat="server" />
</form>
</body></html>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|