XMLNode.Type

From Xojo Documentation

Read-Only Property (As Integer )
IntegerValue = aXMLNode.Type

Supported for all project types and targets.

Integer constant denoting the type, such as Element, Attribute, TextNode, and so forth.

Notes

Use the Class Constants of the XMLNodeType object to compare values.

Examples

The example code below uses this XML. Assign it to a constant called kXML:

 <?xml version="1.0" encoding="UTF-8"?>
 <League>
 	<Team name="Seagulls">
 		<Player name="Bob" position="1B" />
 		<Player name="Tom" position="2B" />
 	</Team>
 	<Team name="Pigeons">
 		<Player name="Bill" position="1B" />
 		<Player name="Tim" position="2B" />
 	</Team>
 	<Team name="Crows">
 		<Player name="Ben" position="1B" />
 		<Player name="Ty" position="2B" />
 	</Team>
 </League>

Display the type of the first team node:

Dim xml As New XmlDocument(kXML)

Dim n As XmlNode = xml.DocumentElement.FirstChild

If n <> Nil Then
Dim nodeType As String

Select Case n.Type
Case XmlNodeType.ELEMENT_NODE
nodeType = "Element"
Case XmlNodeType.ATTRIBUTE_NODE
nodeType = "Attribute"
Case XmlNodeType.TEXT_NODE
nodeType = "Text"
Case XmlNodeType.CDATA_SECTION_NODE
nodeType = "CData Section"
Case XmlNodeType.ENTITY_REFERENCE_NODE
nodeType = "Entity Reference"
Case XmlNodeType.ENTITY_NODE
nodeType = "Entity"
Case XmlNodeType.PROCESSING_INSTRUCTION_NODE
nodeType = "Processing Instruction"
Case XmlNodeType.COMMENT_NODE
nodeType = "Comment"
Case XmlNodeType.DOCUMENT_NODE
nodeType = "Document"
Case XmlNodeType.DOCUMENT_TYPE_NODE
nodeType = "Document Type"
Case XmlNodeType.DOCUMENT_FRAGMENT_NODE
nodeType = "Document Fragment"
Case XmlNodeType.NOTATION_NODE
nodeType = "Notation"
Case XmlNodeType.OTHER_NODE
nodeType = "Other"
Else
nodeType = "Unknown"
End Select

MsgBox("Type: " + nodeType)
End If