publicclass Test
public Shared Sub Main
Dim myDoc As New Xml.XmlDocument
myDoc.Load("test.xml")
Dim chpts As Xml.XmlNodeList = myDoc.SelectNodes("/book/chapters/chapter")
For Each nd As Xml.XmlNode In chpts
Console.WriteLine(nd.Attributes("id").Value)
Next
Dim book As Xml.XmlElement
book = myDoc.Item("book")
Console.WriteLine("ISBN: " & book.Attributes("isbn").Value)
Dim title As Xml.XmlElement
title = book.Item("title")
Console.WriteLine(title.InnerText)
Console.WriteLine("Authors:")
Dim authors As Xml.XmlElement
authors = book.Item("authors")
For Each node As Xml.XmlNode In authors.ChildNodes
If node.Name = "author" Then
Console.WriteLine(node.InnerText)
End If
Next
Dim chapters As Xml.XmlElement
chapters = book.Item("chapters")
For Each node As Xml.XmlNode In chapters.ChildNodes
If node.Name = "chapter" Then
Console.WriteLine(node.Attributes("id").Value)
Console.WriteLine(node.Attributes("topic").Value)
End If
Next
End Sub
End class