Reputation:
<div class="one">
<a class="two" href="Something..."><img src="http://..."/></a>
<p> stuff.... </p>
<p><img src="http://....." /></p>
</div>
I have this silly HTML which I am parsing, as you can see there is one main class called one and another one nested called two. I am trying to parse all the images in class one, but apparently the XPath I have is only catching one image, which is the image from class one
I tried this:
//div[@class="one"]/img | //a[@class="two"]/img
But apparently I am not catching from class two, but only from class one is there anyway to do this?
I am using lxml.html's xpath feature.
Upvotes: 0
Views: 964
Reputation: 185106
Try this Xpath
expression :
//div[@class="one"]//img
Test :
xmllint --html --xpath '//div[@class="one"]//img' \
'http://sputnick-area.net/ftp/downloads/testSO.html'
OUTPUT
<img src="http://...">
<img src="http://.....">
Upvotes: 1