XMLNode.Child

From Xojo Documentation

Method

XMLNode.Child(Index as Integer) As XMLNode

Supported for all project types and targets.

Returns the child XMLNode at the position denoted by Index. Index is zero-based.

Examples

This example loads the following XML, contained in a constant called kTestXml, into a new XMLDocument and then displays the team names:

 <?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>
// Load XML
Var xml As New XmlDocument
Try
xml.LoadXml(kTestXml)
Catch e As XmlException
MessageBox("XML error: " + e.Message)
Return
End Try

For team As Integer = 0 To xml.DocumentElement.ChildCount-1
MessageBox("Team: " + xml.DocumentElement.Child(team).GetAttribute("name"))
Next