Forum Discussion

marin's avatar
marin
Frequent Contributor
12 years ago

How to iterate through array returned by EvaluateXPath()?

Hello all,



maybe I am not seeing the obvious, but I am having problems on iteration through array of elements returend by EvaluateXPath() method.



According to manual, return type of EvaluateXPath() is an array - but in my case all array nodes are "undefined" (see screenhot) - although the parent object exists and is correctly found . The number of found child nodes is also correct.



What is the proper way to populate and  iterate through such an array?

How would it look like for method FindChildByXPath() - the return type of this method is an object?



Many thanks for any hints,



Marin

1 Reply

  • marin's avatar
    marin
    Frequent Contributor
    ...figured out in the meantime:

    it must be a variant to which EvaluateXPath() returns the found objects. Var must be casted to VBArray afterwards:







    var valueArr;

    var objPanel = pgPage.NativeWebObject.Find("ObjectIdentifier", "Div_Content");

    valueArr = objPanel.EvaluateXPath("//DIV[@class='OverviewPanelEntryMain']");

    valueArr = (new VBArray(valueArr)).toArray();