TruClient: How to take the No of rows in a table using XML

I am trying to take the row length from a dynamic table, I tried to use the below code to find the length but its not returning the no of rows, any help will be appreciated.

var r;
var x;
r = document.evaluate("//*[@id=\"grid-control10\"]/p-table/div/div/table/tbody/tr",document,null,XPathResult.ANY_TYPE,null);
x = r.length;
alert(x);

Htm1.PNGHtm2.PNG

Parents
  • Hi,

    The return value of document.evaluate is of type XPathResult which does not have the length property.
    You can try this code:

    var r;
    var x;
    r = document.evaluate("//*[@id=\"grid-control10\"]/p-table/div/div/table/tbody/tr",document,null,XPathResult.ANY_TYPE,null);
    var retVal = [], curVal;
    while (curVal = r.iterateNext())
         retVal.push(curVal);
    alert(retVal.length);

     

    Thanks,

    Michal

  • Hi Michal 

    Thanks for the info, but still i am not able to get the no of rows in the table.

    var r;
    var x;
    r = document.evaluate("//*[@id=\"grid-control8\"]/p-table/div/div/table/tbody/tr",document,null,XPathResult.ANY_TYPE,null);
    var retVal = [], curVal;
    while (curVal = r.iterateNext())
    retVal.push(curVal);
    alert(retVal.length);

    In variable r i am only seeing only one object and the retVal length is showing 0.  Can you help me in how to get the whole rows with document.evalutate.

    Absolute Xpath : //*[@id="grid-control8"]/p-table/div/div/table/tbody/tr[1]/td[11]/span/span

    When i use evalXpath, the result shows all the objects in the table but the same i am not able to use it in JavaScript code, it's working only in EvaluateJsonObject.

     

     

Reply
  • Hi Michal 

    Thanks for the info, but still i am not able to get the no of rows in the table.

    var r;
    var x;
    r = document.evaluate("//*[@id=\"grid-control8\"]/p-table/div/div/table/tbody/tr",document,null,XPathResult.ANY_TYPE,null);
    var retVal = [], curVal;
    while (curVal = r.iterateNext())
    retVal.push(curVal);
    alert(retVal.length);

    In variable r i am only seeing only one object and the retVal length is showing 0.  Can you help me in how to get the whole rows with document.evalutate.

    Absolute Xpath : //*[@id="grid-control8"]/p-table/div/div/table/tbody/tr[1]/td[11]/span/span

    When i use evalXpath, the result shows all the objects in the table but the same i am not able to use it in JavaScript code, it's working only in EvaluateJsonObject.

     

     

Children