XPath: returning the index of specific tag inside a set of tags with the same type -
here excerpt of xml:
<table> ... <tbody> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </tbody> </table>
i know how find specific <tr>
tag.
is possible define <tr>
tag index or ordinal number inside <tbody>
tag? guess, it's possible loop through table, table quite large , take lots of time.
is possible index/ordinal number single xpath statement?
i've used following xpath expression:
//tbody//td[text()='findme']/../following-sibling::tr
these expression calculates, how many 'tr' nodes located under node 'findme' text. actually, useful, because quantity of 'tr' nodes obtained.
but, prior given xpath, verification should made, because in case 'finme' string absent, xpath return 0. following expression works validation fine:
//tbody//td[text()='findme']
Comments
Post a Comment