How to parse a html table data through table id using JSoup in java

html-parser, html-parsing, java, jsoup

Solution

Try this

doc.select("table#AutoNumber5");

It worked for me.

Reference : http://jsoup.org/apidocs/org/jsoup/select/Selector.html

Problem

I need to store my client's table data into database. There are n number of tables for which they have not provided any table class (directly using just Table_id in web page). Example: ``` [table width="100%" border="0" cellpadding="0" cellspacing="0" id="AutoNumber5" style="border-collapse: collapse" bordercolor="#111111"]<br/> [table width="100%" border="0" cellpadding="0" cellspacing="0" id="AutoNumber4" style="border-collapse: collapse" bordercolor="#111111" ] ``` If there is a Table Class, obviously i can parse it easily, but there is no class just id is given in table. I know there would be only one word syntax, except ``` for (Element table : doc.select("table") ``` Maybe I could not find it. How to find it ? I have tried `for (Element table : doc.select("table.AutoNumber5")` But it's not working for me. How to fix this?

Original source