|
The ProgrammingMSAccess.COM Site This procedure demonstrates how to use the xmltextreader object to parse all the nodes and attributes in an xml document. Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click
'Specify a path for the 'xml file to read Dim strXMLPathFile As String = "..\temp.xml"
'Construct an XMLTextReader for 'the xml file Dim xtr1 As New System.Xml.XmlTextReader (strXMLPathFile)
'Read through Nodes in reader, 'print the type, name, and 'value for all elements; also, 'print attribute names and 'values for elements Do While xtr1.Read Console.WriteLine("NodeType: {0} " & ControlChars.CrLf & _ "Name: {1} " & ControlChars.CrLf & "Value: {2}", _ xtr1.NodeType.ToString, xtr1.Name, xtr1.Value) If xtr1.HasAttributes Then Do While xtr1.MoveToNextAttribute Console.WriteLine(ControlChars.Tab & "{0} = {1}", _ xtr1.Name, xtr1.Value) Loop End If Console.WriteLine() Loop
'Close reader xtr1.Close() End Sub
Learn more about VB.NET programming from either Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .NET or Programming Microsoft Visual Basic .NET for Microsoft Access Databases. Copyright 2003 CAB, Inc. All rights reserved. Republication or redistribution
of CAB, Inc. content, including by framing or similar means, is expressly
prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be
liable for any errors in the content, or for any actions taken in reliance
thereon.
|