XMLFind

Use this function to locate the XML path from the extracted XML tree and return a list of matched elements to either a:

The result depends on the search request.

Syntax

XMLFind (%xXMLTree, SrchNode, XPath)

Parameter

Description

%xXMLTree

A list type DAL variable which is passed from either the XMLFileExtract rule or the LoadXMLList function.

You can use the predefined %extract variable as a parameter here, as discussed in scenario 1.

SrchNode

A string type DAL variable that passes a node name from which the search starts.

If you omit this parameter, the search starts from the r£oot of the XML tree.

XPath

A string type DAL variable that passes the XML location. If you omit the second parameter, the search starts from the root of the XML tree.

The system returns a list type or a string type DAL variable.

Example

This example returns text from the last element in the list.

aStr="Text not found!";
%xXMLTree=LoadXMLList("test.xml");
%XMLTree=XMLFind(%xXMLTree,"Forms","Form[text()]");
#rc=XMLFirst(%XMLTree);
loop:
if #rc=0
goto endloop:
end
aStr=XMLGetCurName(%XMLTree);
#rc=XMLNext(%XMLTree);
goto loop:
endloop:
#rc=DestroyList(%xXMLTree);
return(aStr);

See also