XmlGetAttributeByName Function

Action

Returns the value of a nodes attribute. The attribute is identified by the attributes name.

Include file

XmlAPI.bdh

Syntax

XmlGetAttributeByName( in    hNode      : number,
                       in    sAttrName  : string,
                       inout sValue     : string,
                       in  nMaxValueLen : number optional ): boolean;

Return value

  • true if successful

  • false if failed

Parameter Description
hNode Handle to an XML node
sAttrName Name of the attribute that should be returned.
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>");
    hResult := XmlSelectSingleNode(hDocument, "/root/child2");
    XmlGetAttributeByName(hResult, "attr1", sValue);
  end TMain;