ODAC

TOraXML.Extract Method

Extracts the given set of nodes from the TOraXML.

Class

TOraXML

Syntax

procedure Extract(RetDoc: TOraXML; XPathExpr: string; NSmap: string = '');

Parameters
RetDoc
Holds a destination TOraXML object which holds the operation result.
XPathExpr
Holds an expression that specifies the set of nodes to extract.
NSmap
Holds a namespace map of TOraXML.

Remarks

Call the Extract method to extract the given set of nodes from the TOraXML. This set of nodes is specified by the XPathExpr expression. The original document remains unchanged. If no nodes match the specified expression, returns NULL document. RetDoc parameter is a destination TOraXML object which holds the operation result. RetDoc object must be created before passing it as a parameter. Use XPathExpr parameter to specify what nodes to search for. The NSmap parameter is a namespace that can be used to identify the mapping of prefix(es) specified in the XPath_string to the corresponding namespace(s). The format is "xmlns=a.com xmlns:b=b.com".

Example

var
   RetDoc: TOraXML;
   Str: string;
begin
...
   Edit;
   TOraXMLField(FieldByName('XMLField')).AsXML.AsString := 
      '<root> '+
      '<x xmlns:edi=''http://ecommerce.org/schema''> '+
      '<b>32.18</b> '+
      '<edi:price units=''Euro''>32.18</edi:price> '+
      '</x> '+
      '</root>';
   Post;
...
   RetDoc := TOraXML.Create();
   RetDoc.OCISvcCtx := OraSession1.OCISvcCtx;
   try
      with TOraXMLField(FieldByName('XMLField')).AsXML do begin
         Extract(RetDoc, '//edi:price', 'xmlns:edi=http://ecommerce.org/schema');
         Str := RetDoc.AsString; 
         Extract(RetDoc, '/root/x/b');
         Str := RetDoc.AsString; // Str = '<b>32.18</b>'
      end;
   finally
      RetDoc.Free;
   end;
end; 

See Also

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback