XmlGetChildByIndex Function


Returns a handle to a child node of the passed node/document handle. The child node is identified by its index where the first child has index 0.

A document node can also have multiple child nodes because XML documents can have multiple processing instructions on the first level. But there can only be one element node at the root level of a document.

Include file



XmlGetChildByIndex( in hDocNode : number,
                    in nIndex   : number ): number;

Return value

  • node handle if successful

  • 0 if failed

Parameter Description
hDocNode Handle to an XML node/document If the handle is a document handle, a root element will be returned. Normally there is only one root element - except if there are processing instructions.
nIndex Child index that should be returned. Index of first child is 0.


  transaction TMain
   hDocument, hRoot, hRootChild: number;
    hDocument := XmlCreateDocumentFromXml( "<root><child1 attr1='avalue1'>childvalue1</child1>"
                 "<child2 attr1= 'avalue2'>childvalue2</child2></root>");
    Root     := XmlSelectSingleNode(hDocument, "/root");
    hRootChild:= XmlGetChildByIndex(hRoot, 0 );
  end TMain;