Reputation: 499
<div class="a">
<div>Histogram
<em>Median</em>
</div>
<div>
<em>Median</em>
</div>
</div>
In this case, how to get the second node contains 'Median' using xpath?
//div[@class="a"]//*[text()="Median"]
will give two nodes.
Upvotes: 0
Views: 49
Reputation: 33384
Try the below xpath
.
(//div[@class='a']//em[text()='Median'])[last()]
Upvotes: 0
Reputation: 13006
you can use following-sibling
//div[@class="a"]/div[em[text()="Median"]]/following-sibling::div/em
Upvotes: 1