Question

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?

Was it helpful?

Solution

Try this

doc.select("table#AutoNumber5");

It worked for me.

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

OTHER TIPS

jsoup support css selectors and if you know the css it is easy to use like this:

Document doc = Jsoup.connect("http://xxxxxxxx.com/").get();

Elements el = doc.select("#targeted-elemnet-id");

you only need to replace your element id after # sign without space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top