Skip to content

getChildAttrib(xmlID, childAttribName)

The getChildAttrib(xmlID, childAttribName) method gets the string value of the first child attribute regarding the current main position element.

It returns an empty string if:

  • There aren't attributes that match the specified attribute name.

Or:

  • There isn't a child position.

Or:

  • The child position element has no attribute.

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 attLabel = XML.getChildAttrib(xmlID, "LABEL"); 

returns one.one.one in the attLabel variable.

The syntax is:

XML.getChildAttrib(xmlID, childAttribName)

where:

  • xmlID is the ID of the XML document.
  • childAttribName is the child attribute name element from which to get the string value.