I am trying to store the array list in a variable but have no clue how to solve it.
The xpath will return a list of items, and it is displayed in console just fine. My issue is that I have no idea how I could store it in a variable to use the list later.
If I try to use "arrayList" it will only return the last item from the array, but in console it displays all items.
Any ideas?
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);
}
arrayEpisodes, and why are you not using the indexarrayList[i]in your loop?textContentis a string, so not sure why you are iterating it. Also, try to putvar thisNode = iterator.iterateNext();at the end of the while. If you want to store the items, create an array and stash them. I will add a snippet to solution.