Javascript Table Management in TruClient

Hi,

Using LoadRunner 24.1
I've opened an "Evaluate Javascript code". I put this

A.
// I want to use a javascript table

var options = getElementByXpath("//app-document-section/div/div/div/app-single-document/div[2]/span");
for (i=0;i<options.length;i++)
{
    TC.log(options[i].textContent);
}

function getElementByXpath (path) {
  return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

When I execute in VuGen this scriptlet, I have nothing

B.
but if I use this, it works

// n varying from 1 to 25 for example

var options = getElementByXpath("//app-document-section/div/div/div/app-single-document/div[2]/span[n]");
TC.log(options.textContent); // returns "3" the good content

How can I do to use option A as my goal is to obtain max of table options.