Executing X-Path Queries

You can execute X-Path queries on a document or on nodes of a document. If you execute the query on the document, the root element is the initial point for the query - otherwise it is the node. There are two functions to execute an X-Path Query. XmlSelectNodes returns node list with all nodes that match the query. XmlSelectSingleNode returns the first node that matches the query. For a detailed description of X-Path, see the online documentation at http://www.w3c.org.

dcltrans
transaction TMain
var
  hDoc, hChildren, hRoot, hChild : number;
begin
  hDoc      := XmlCreateDocumentFromXml("<root><child>value1</child><child>value2</child></root>");
  hRoot     := XmlSelectSingleNode(hDoc, "/root");
  hChildren := XmlSelectNodes("/root/child");
  hChild    := XmlGetItem(hChildren, 1);
  ...
  XmlFreeHandle(hChild);
  XmlFreeHandle(hChildren);
  XmlFreeHandle(hRoot);
  XmlFreeHandle(hDoc);
  XmlFreeHandle(hDoc);
end TMain;