Skip to content Skip to sidebar Skip to footer

Count From The List

Say I have a xpath like below //div[contains(@class, 'cat 53453463')]/a and the page contains many of these with different Xes //div[contains(@class, 'cat xxxxxx')]/a Does xpath

Solution 1:

In XPath 2.0 you can get the position of a node $N within a node-list $L using the expression

for$iin1 to count($L) return$i[$L[$i] is$N]

I don't think it can be done in XPath 1.0 (but I've been wrong before...)

Post a Comment for "Count From The List"