Feature #1467

Updated by Serge Heiden over 4 years ago

Currently, The getXpathResponse method of the XPathResult.groovy script/class API provides XPathResult class returns only two 'all in memory' model methods:
* getXpathResponse returns
the first match of an XPath
* getXpathResponses returns all the string values of the matches of an XPath as an array of strings

To be able to process large XML files with lots of elements matching Add a given XPath, we need to add to the API a way not to store the intermediate array of strings in memory. The new method can limit the memory consumption used to transmit the result XPathResult class implementing an iterator to only successively retrieve all the one used for the list matches of DOM result nodes.

h3. Solution

Add a new streamingGetXpathResponses method with the code of getXpathResponses where:
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
//println nodes.item(i)
return xresult
is replaced by:
NodeList nodes = (NodeList) result
return nodes

The Groovy code calling streamingGetXpathResponses can then iterate the results with:
nodes.each { println it.getNodeValue() }
an XPath.