Note that there are some explanatory texts on larger screens.

plurals
  1. POJava (Android) Html Table Parsing to Database (SQLite)
    primarykey
    data
    text
    <p>I have searched far and wide for a number of days now trying to find the answer to the following problem. I am pretty new to Java and Android programming and have learnt mainly from copy-paste-edit scenarios, but despite there being a few tutorials around I am really struggling with this one.</p> <p>I have tried htmlcleaner as my parser, and I'm sure I'm close but just cant get this right.</p> <p>I am trying to parse a table of values on a website (i.e. <code>&lt;TR&gt;TD,TD,TD,TD&lt;/TR&gt;</code>) into a standard Android SQLite database. So each row of the table would be a row in the db.</p> <p>In theory this should be quite simple but I am getting snowed under with different methods and not understanding a simple clean way to do it.</p> <p>Can anybody help? Please don't point me to a htmlparser or non-specific tutorial because I have worked at these for ages and can't manage a solution.</p> <p>The table values I am trying to parse are here: <a href="http://news.bbc.co.uk/mobile/bbc_sport/rugby/competition/ru100/table/index.shtml?context=cps_ukfs" rel="nofollow noreferrer">Teams and values</a></p> <p>EDIT:::</p> <p>OK I think I'm getting close using JSoup. I can grab a value from within a [td] tag and put it to a string. However, how can I adapt the following code so that each row (i.e. within each [tr]) is iterated for each 'for', and each [td] value is put to a String array?</p> <pre><code>public class GetTable extends Activity { static String hello; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.testlayout); try { populateTexts(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void populateTexts() throws IOException{ String url = "http://news.bbc.co.uk/mobile/bbc_sport/rugby/competition/ru100/table/index.shtml?context=cps_ukfs"; Document doc = Jsoup.connect(url).get(); Elements links = doc.select("td"); for (Element link : links) { hello = link.text(); TextView twittertext10 = (TextView)findViewById(R.id.testView1); twittertext10.setText(hello); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload