XmlChildPos()

Gets the position of a child element within an XML document object.

The position, in an XmlChildren array, of the Nth child that has the specified name.

XmlChildPos( node=xml, childName=string, index=number );

Returns: Number

Argument Description
node
xml, required

XML element within which to search.

Alias: xmlNode, xmlObj, xmlDoc, xml

childName
string, required

XML child element for which to search

index
number, required

Index of XML child element for which to search

Examples

xml_stream = "
  <notes>
    <note>
      <to>Alice</to>
      <from>Bob</from>
      <heading>Reminder</heading>
      <body>Here is the message you requested.</body>
    </note>
    <author>
      <first>John</first>
      <last>Doe</last>
    </author>
  </notes>
";

xml_document = XmlParse(xml_stream); xml_root = xml_document.XmlRoot;

dump(XmlChildPos(xml_root,"author",1)); // 2

See also