%XML_ELEM_GETELEMENTSBYNAME

Get children of an XML element by tag

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
elem_list = %XML_ELEM_GETELEMENTSBYNAME(element, tag_name)

Return value

elem_list

The XML element list of all children with the specified tag name directly under the specified XML element, or 0 if no children are found. (XML_ELEMLIST_TYPE)

Arguments

element

The XML element instance whose children will be listed. (XML_ELEM_TYPE)

tag_name

The tag name of the children to list. (a)

Discussion

%XML_ELEM_GETELEMENTSBYNAME uses a tag name to retrieve a list of child XML elements for the specified parent element. Element lists explicitly created with this routine will need to be deleted using %XML_ELEMLIST_DELETE.

This function is defined as ^VAL.

Examples

We’ll use the following portion of an XML document as an example:

<structure name="mystruct" >
  <group name="mygroup" />
  <field name="f1" />
  <field name="f2" />
</structure>

Assuming parent is the structure element,

%xml_elem_getElementsByName(parent, "field")

will return a list that contains two children, f1 and f2.

Also see Example of parsing XML.