XmlSelectSingleNode Function

Action

Executes an X-Path query on the passed handle (either document or node) and returns the first resulting node handle. If the query returns no handles, XmlSelectSingleNode returns 0. For a detailed description of X-Path, check the specification at http://www.w3c.org. The root node for the query is the passed node/document handle.

Include file

XmlAPI.bdh

Syntax

XmlSelectSingleNode( in hDocNode : number,
                     in sQuery   : string ): number;

Return value

  • node handle if successful

  • 0 otherwise

Parameter Description
hDocNode A valid document or node handle
sQuery X-Path query that will be executed on the handle that is passed.

Example

dcltrans
  transaction TMain
  var
   hDocument, hResult, hItem : number;
   sAttrValue                : string;
  begin
    hDocument := XmlCreateDocumentFromFile("C:\\MyXMLDocuments\\Order.xml");
    hItem := XmlSelectSingleNode(hDocument, "//OrderItem[1]");
    XmlGetAttributeByName(hItem, "price", sAttrValue);
  end TMain;