XObject.NodeType Property gets the node type for this XObject.
Imports System
Imports System.Xml
Imports System.Xml.Schema
Class MainClass
Shared Sub Main()
Dim xmlTree As XDocument = _
<?xml version="1.0"?>
<!--a comment-->
<?xml-stylesheet type="text/xsl" href="hello.xsl"?>
<Root Att="attContent">
<Child1>content</Child1>
<Child2>Text content</Child2>
</Root>
For Each node As XNode In xmlTree.DescendantNodes
Console.WriteLine(node.NodeType.ToString())
If node.NodeType = XmlNodeType.Element Then
For Each att In DirectCast(node, XElement).Attributes
Console.WriteLine(att.NodeType.ToString())
Next
End If
Next
End Sub
End Class