I have the below xpath expression
//div[@class="post-content"]//img
which runs on a html page, scanning for images. The above query returns a lot of images but I only want the second in the list.
I have tried
//div[@class="post-content"]//img[1] and
//div[@class="post-content"]//img[position()=1]
with no luck
How can I do it?
thanks
indexes in XPath are 1-based, not 0-based. Try
In XPath index starts from 1 position, therefore
should work correctly if you have to select each 2nd
img
indiv[@class="post-content"]
. If you have to select only 2ndimg
from all images that are indiv[@class="post-content"]
, use: