XmlFreeHandle Function

Action

XmlFreeHandle should be called on node, nodelist and document handles as soon as they are no longer needed in the script to keep memory usage low. If no parameters are passed, all currently used handles are freed and are then no longer valid.

You can pass a handle to a document, node or nodelist handle. If you pass true for parameter bAndDepending and the passed handle is a document handle, all handles to nodes of this document will also be freed and are then no longer valid.

Include file

XmlAPI.bdh

Syntax

XmlFreeHandle( in hHandle          : number optional,
               in bAndDepending    : boolean optional ): boolean;

Return value

  • true if succeeded

  • false if failed

Parameter Description
hHandle A valid document/node/nodelist handle If omitted, all handles that are still in use will be freed.
bAndDepending If the handle is a document handle and bAndDepending is true, all handles for this document will be freed.

Example

dcltrans
  transaction TMain
  var
  hDocument, hResult, hOrderItems, hItem, hCount : number;
  itemIx                                         : number;
  sAttrValue                                     : string;
  begin
    hDocument := XmlCreateDocumentFromFile ("C:\\MyXMLDocuments\\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;
 
    XmlFreeHandle();
  end TMain;