XmlSelectNodes Function

Action

Executes an X-Path query on the passed handle (either document or node) and returns the resulting handles in a node list. If the query returns no handles, XmlSelectNodes returns a valid nodelist handle with no containing nodes (so XmlGetCount would return 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

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

Return value

  • node list 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 : number;
    hOrderItems, hItem : number;
    hCount, itemIx     : number;
    sAttrValue         : string;
  begin
    hDocument : XmlCreateDocumentFromFile("C:\\MyXMLDocume nts\\Order.xml");
    hOrderItems := XmlSelectNodes(hDocument, "//OrderItem");
    hCount := XmlGetCount(hOrderItems);

    for itemIx := 0 to hCount - 1 do
      hItem := XmlGetItem(hOrderItems, itemIx);
      XmlGetAttributeByName(hItem, "price", sAttrValue);
    end;
  end TMain;