Treating elements with the same name as an array

In many cases, an XML element has multiple children with the same name. For example, the example document used in many XML examples has multiple name elements in the employee elements. In many cases, you can treat the child elements with identical names as an array. For example, to reference the second name element in mydoc.employee, you can specify mydoc.employee.name[2]. However, you can only use a limited set of Array functions when you use this notation. The following table lists the array functions that are valid for such references:

Array function

Result

IsArray(elemPath.elemName)

Always returns False.

ArrayClear(elemPath.elemName)

Removes all the elements with name elemName from the elemPath element.

ArrayLen(elemPath.elemName)

Returns the number of elements named elemName in the elemPath element.

ArrayDeleteAt(elemPath.elemName, n)

Deletes the nth child named elemName from the elemPath element.

ArrayIsEmpty(elemPath.elemName)

Always returns False.

ArrayToList(elemPath.elemName, n)

Returns a comma-separated list of all the XmlText properties of all the children of elemPath named elemName.