Imports System Imports System.Xml Imports System.IO Imports System.Collections Imports Microsoft.VisualBasic 'http://support.microsoft.com/default.aspx?scid=kb;EN-US;q301225 Public module MyModule Sub Main() 'Dim strFile as String = Application.StartupPath() & "\SavedSnippets\SampleData\Contacts.xml" Dim strPath as String = "C:\Documents and Settings\Dan\Desktop\CodeSnippetCompiler\SavedSnippets\SampleData\" Dim strFile as String = strPath & "\Classes.xml" Dim strRecordName as String = "//Class" Dim strOutput as String ReadXML(strFile, strRecordName) Console.Write("Press Enter to Continue") Console.ReadLine() End Sub Sub ReadXML(byVal strXmlFileName as String, byVal strRecordName as String) 'as HashTable Dim ht as New HashTable ' http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317663 ' Create an Xml document instance and load XML data. Dim doc As XmlDocument = New XmlDocument() doc.Load(strXmlFileName) ' 1. Select all the Book titles by using an XPath query. Dim nodeList As XmlNodeList = doc.SelectNodes(strRecordName) Dim node As XmlNode Dim root As XmlElement = doc.DocumentElement 'node = root.FirstChild Dim i as Integer = -1 For Each node In nodeList i += 1 Dim cNode As XmlNode If node.HasChildNodes Then Console.WriteLine("") Console.WriteLine("Class Number: " & i.ToString) For Each cNode In node.ChildNodes Dim strField as String Select Case cNode.LocalName Case "Date": strField = "Date" Case "DayOrNight": strField = "Time" Case "Description": strField = "Description" Case "Status": strField = "Status" Case "Instructor": strField = "Instructor" Case Else: strField = "??? [" & cNode.LocalName & "]" End Select Console.Write(" " & strField & ": ") Console.WriteLine("{0}", cNode.InnerText) Next End If Next End Sub End Module