XmlGetAttributeByIndex Function

Action

Returns the value of a nodes attribute. The attribute is identified by the attribute's index - beginning with 0 for the first attribute.

Include file

XmlAPI.bdh

Syntax

XmlGetAttributeByIndex( in  hNode : number,
                        in  hIndex       : number,
                        out sValue       : string,
                        in  nMaxValueLen : number optional ): boolean;

Return value

  • true if successful

  • false if failed

Parameter Description
hNode Handle to an XML node
hIndex Index of the attribute that should be returned. Index for first element is 0.
sValue String variable that receives the value of the attribute
nMaxValueLen Maximum length of the string to return (optional). If this parameter is omitted or set to STRING_COMPLETE all available data is stored in sValue.

Example

dcltrans
  transaction TMain
  var
    hDocument, hResult : number;
    sValue: string;
  begin
    hDocument := XmlCreateDocumentFromXml("<root><child1 attr1='avalue1'>childvalue1</child1>"
                "<child2 attr1= 'avalue2'>childvalue2</child2></root>");
    hResult := XmlSelectSingleNode(hDocument, "/root/child2");
    XmlGetAttributeByIndex(hResult, 0, sValue);
  end TMain;