Skip to content

findElem(xmlID, elementName)

The findElem(xmlID, elementName) method moves the current main position to the next matching same level element specified by the elementName parameter.

It returns a boolean value of true if it is found, false otherwise.

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

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

The instruction:

var findNext = XML.FindElem(xmlID, "DOMAIN"); 

returns true in the findNext variable because there is at least another DOMAIN element on the same level.

If there is no current position, typically when you open a document, calling findElem(xmlID, elementName) will set the main position to the DOMAINTREE element. Calling findElem(xmlID, elementName) a second time will return false and the main position doesn't change from the DOMAINTREE element.

See the intoElem(xmlID) method to understand how to change the position after opening a file.

The syntax is:

XML.findElem(xmlID, elementName);


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