I am struggling to save the array list in a variable and I'm not sure how to go about solving this issue.
The xpath query successfully retrieves a list of items, which are being displayed in the console without any problems. However, I am unable to figure out a way to store this list in a variable for later use.
When I attempt to assign the values to an "arrayList" variable, only the last item from the array is returned despite seeing all items in the console output.
Does anyone have any suggestions on how to tackle this problem?
var iterator = document.evaluate('xpathgoeshere', document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
try {
var thisNode = iterator.iterateNext();
while (thisNode) {
var arrayList = (thisNode.textContent);
var thisNode = iterator.iterateNext();
for (var i = 0; i < arrayList.length; i++) {
console.log(arrayList);
}
}
} catch (e) {
dump('Error: Document tree modified during iteration ' + e);
}