Reputation: 994
I've this HTML code with a lot of these blocks:
<tr>
<td headers="header1"><b><a href="www.site.com">TITLE</a></b></td>
<td headers="header2"><ul class="list_attachments">
<li><a href="/"><img src='/img/fileicons/pdf.png' alt='pdf'/>A</a>
</li><li><a href=""><img src='/img/fileicons/pdf.png' alt='pdf'/> B</a>
</li></ul></td><td headers="header3" class="centrato">DATE</td></tr>
<tr>
In order to iterate in all of these blocks, I tried:
Elements elements = document.select("tr").select("td[headers=header1]");
This command works, but only select
<td headers="header1"><b><a href="www.site.com">TITLE</a></b></td>
instead of all the block. How can I solve this? Isn't possible to say: "jsoup, please select all the blocks that have an inner ?
Upvotes: 0
Views: 208
Reputation: 66
To accomplish the task of selecting all <tr>
blocks that contain an inner <td headers="header1">
, I propose the following solution.
Elements elements = document.select("tr:has(td[headers=header1])");
Upvotes: 1