indexing - How to get element's index by xpath? -
i've next structure :
<div id='list'> <div class='column'>aaa</div> <div class='column'>bbb</div> ... <div class='column'>jjj</div> </div>
i wonder if there ways use xpath, , write query can index of requested element within "list" element.
i mean i'll ask location of class='column'
text value aaa
, i'll 0
or 1
...
thanks
you count div elements preceding element you're looking for:
count(div[@id = 'list']/div[@id = 'myid']/preceding-sibling::div)
Comments
Post a Comment