Im using JSoup with android and so far I have been successful. In my original activity I referenced a table and from that each individual cell in a table by code. My question is how would I have Jsoup get the results of a table based on some parameter?
For example if I wanted to get the 3rd row of a table - ( get its contents ). Any resources beside whats on the Jsoup site would do as I find that hard to follow.
Thanks
You could do something like this:
String html = "<table id=\"myTable\"><tr><td>First</td></tr><tr><td>Second</td></tr><tr><td>Third</td></tr></table>";
Document doc = Jsoup.parse(html);
System.out.println(doc.select("#myTable").select("tr").get(1));
Output:
<tr>
<td>Second</td>
</tr>
That is the second row in the table.
Try
"table tr:eq(3)"
http://jsoup.org/cookbook/extracting-data/selector-syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With