Skip to content

findChildElem(xmlID, childElementName)

The findChildElem(xmlID, childElementName) method locates the first child element, specified by the childElementName parameter, under the current main position.

The method sets the child position if there is a main position and no current child position.

If the child position is found, the method returns a boolean value of true, false otherwise.

If there is a child element, the position moves to the next child element.

If there isn't a child element or no next child element, the method returns a boolean value of false and the child position is not affected.

For example, considering the following XML document and the related current positions:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOMAINTREE>
    <DOMAIN NAME="1" LABEL="one">                           <-- Parent position
        <DOMAIN NAME="1.1" LABEL="one.one">                 <-- Main position
            <DOMAIN NAME="1.1.1" LABEL="one.one.one"/>      <-- Child position
            <DOMAIN NAME="1.1.2" LABEL="one.one.two"/>
        </DOMAIN>
    </DOMAIN>
    <DOMAIN NAME="2" LABEL="two"/>
    <DOMAIN NAME="3" LABEL="three"/>
</DOMAINTREE>

The instruction:

var chElem1 = XML.FindChildElem(xmlID, "DOMAIN"); 

returns true in the chElem1 variable because there is a child with the DOMAIN element.

The syntax is:

XML.findChildElem(xmlID, childElementName);

where:

  • xmlID is the ID of the XML document.
  • childElementName is the child element to check.