Imports System
Imports System.Text
Imports System.Xml
Imports System.Xml.Schema
Imports System.Collections
Imports System.Collections.Generic
Class MainClass
Shared Sub Main()
Dim xmlTree As XElement = _
1Some Text
2
GrandChild Content
3
Dim node As XNode = xmlTree.Element("Child2")
Do
Dim sb As StringBuilder = New StringBuilder()
sb.Append(String.Format("NodeType: {0}", node.NodeType.ToString().PadRight(10)))
Select Case node.NodeType
Case XmlNodeType.Text
sb.Append(DirectCast(node, XText).Value)
Case XmlNodeType.Element
sb.Append(DirectCast(node, XElement).Name)
Case XmlNodeType.Comment
sb.Append(DirectCast(node, XComment).Value)
End Select
Console.WriteLine(sb.ToString())
node = node.NextNode
Loop While (Not (node Is Nothing))
End Sub
End Class