I have a table like this that i want to Parse to get the data-code value of row.id
and the second and third column of the table.
<table>
<tr class="id" data-code="100">
<td></td>
<td>18</td>
<td class="name">John</td>
<tr/>
<tr class="id" data-code="200">
<td></td>
<td>21</td>
<td class="name">Mark</td>
<tr/>
</table>
I want to print out.
100, 18, John
200, 21, Mark
I have tried the following suggestion from this thread but its not selecting anything how to parse a table from HTML using jsoup
URL url = new URL("http://www.myurl.com");
Document doc = Jsoup.parse(url, 3000);
Element tables = doc.select("table[class=id]");
for(Element table : tables)
{
System.out.println(table.toString());
}
EDIT: also tried using Jsoup.connect() instead of parse()
Document doc = null;
try
{
doc = Jsoup.connect("http://www.myurl.com").get();
}
catch (IOException e)
{
e.printStackTrace();
}