Reputation: 245
I'm hoping there's a better way of doing this than what I've already done. I've got an xpath statement that like this
'//div[@class="findthis"]/a[1]/text()|//div[@class="findthis"]/a[2]/text()|...//div[@class="findthis"]/a[10]/text()'
doing it this way feels very dumb, is there a more elegant way to do this?
Upvotes: 0
Views: 122
Reputation: 163322
If you want the text node children of the first ten a
elements, that would be
//div[@class="findthis"]/a[position() <= 10]/text()
(But you've accepted an answer which does something quite different to your original expression, so it's not really clear what you are looking for.)
Upvotes: 0
Reputation: 1280
This should do the trick:
//div[@class="findthis"]//a//text()
This will find all text descendands of all a
attributes
Upvotes: 1