G
G
Groofy2015-03-16 11:50:30
XPath
Groofy, 2015-03-16 11:50:30

How to select the first image in a div using xpath?

Given

Div with the given class containing two pictures

Required
Select first image via xpath

Example
<div class="tovar">
    <img src='/bin.aspx?ID=aabbccdd'>
    <br>
    <img id='img' src="/imgs/buy.gif">
</div>

Such a request does not work, perhaps due to other tags or something else that I cannot describe

//div[@class="tovar"]/img
Therefore, I am interested in how to limit the choice to the first img

Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krypt3r, 2015-03-16
@Groofy

//div[@class="tovar"]/img[1]
However, it will not work for you - unclosed tags

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question