7.5

Table Of Contents
define(&numberOfItems, integer, xmlcount('/MyData/CUSTOMER/INVOICES/INVOICE/ITEM'))
for(&i, 1, 1, &numberOfItems)
&currentItemDescription := xmlget('-
/MyData/CUSTOMER/INVOICES/INVOICE/ITEM['+inttostr(&i)+']/Description')
show(&currentItemDescription)
crlf()
endfor()
xmlGet()
Retrieves a data selection value through the structure of an XML file. This function uses a single parameter specifying the Path
of the value to be retrieved. This function returns a string. The return value is an empty string if no value is found or if the spec-
ified Element is invalid or not found.
Syntax
xmlGet(path:string) string value
Arguments
path
The XMLPath of the value you want to retrieve. The path must correspond to a single entry in the XML, thus is not a complete
XPath with regular expressions and variables.
Code Sample
These are examples of xmlGet()commands returning data from an XMLfile. Note that these will most likely not work with
your own XMLeven if you tried, as the path is completely dependent on the exact structure of your XMLData file.
define(&myVar, string, '')
&myVar := xmlget('/PLANETPRESS_DATA_FILE[1]-
/CUSTOMER[1]/INVOICES[1]/INVOICE[1]/ITEM[1]/Description[1]')
&myVar := xmlget('/MyData/CUSTOMER[1]/INVOICES[1]/INVOICE[1]/ITEM[1]/Description[1]')
% This next line uses the &i variable to dynamically select an item in the invoice. Use-
ful in a repeat & overflow
% configuration, or a manual PlanetPress Talk loop through te data. Note that the var-
iable must be converted to a string.
&myVar := xmlget('-
/MyData/CUSTOMER[1]/INVOICES[1]/INVOICE[1]/ITEM['+inttostr(&i)+']/Description[1]')
Example 2
The following gets the number of items in an invoice, loops through each item and displays the item's description with show().
define(&i, integer, 0)
define(&currentItemDescription, string, '')
define(&numberOfItems, integer, xmlcount('/MyData/CUSTOMER/INVOICES/INVOICE/ITEM'))
©2010 Objectif Lune Inc - 374 -