Reputation: 12729
This javascript (hosted on a browser console) ...
var xmlDoc = jQuery.parseXML("<foo>Stuff</foo>");
for (let item of SaxonJS.XPath.evaluate( '/foo/text()', xmlDoc,
{resultForm:'iterator'})) {console.log(item);}
... returns error ...
SaxonJS.XPath.evaluate(...) is not a function or its return value is not iterable
... instead of the expected output ...
"Stuff"
Why?
According to documentation here, the evaluate() expression should return an iterator. But it does not.
Libraries used include:
I can get a functionally correct result with this alternative expression ...
for (let item of SaxonJS.XPath.evaluate('string(foo/text())',xmlDoc,
{resultForm:'array'})) {console.log(item)}
... but I really want to use a lazy iterator, if that is possible, rather than an array.
Upvotes: 0
Views: 176
Reputation: 12729
Ok, I think I am just invoking iterator wrong. This works ...
SaxonJS.XPath.evaluate( '/foo/text()', xmlDoc,
{resultForm:'iterator'}).forEachItem( function( node){
console.log( node)})
Upvotes: 1