parsing - Jsoup Android Fetching Info -


hello guys have been having issues jsoup, trying fetch(parse) info site app http://websemantics.co.uk/tutorials/accessibility_workshop/sessions/session2/03.data_tables/01.simple_data_tables/

i want fetch number of candidates colum separte strings of biology math, science etc. value parsed , attached string. how can it, can give example code?

my take on be:

//get site , parse document doc = jsoup.connect("http://websemantics.co.uk/tutorials/accessibility_workshop/sessions/session2/03.data_tables/01.simple_data_tables/").get(); //select table  element table = doc.select("table").first();         iterator<element> iterator = table.select("td").iterator();         while(iterator.hasnext()){             system.out.println("text : "+iterator.next().text()); string math = text(); 

i tried different way not giving anything

element table = doc.select("table").first();                  iterator<element> iterator = table.select("td").iterator();                  while(iterator.hasnext()){                     element row1 = table.select( "td:eq(1)").first();                     string rowno1 = row1.text();                                                 element row2= table.select( "td:eq(1)").first();                     string rowno2 = row2.text(); 

i don't know how further this, can explain doing wrong?

thank you

you want lines, not columns, should <tr>s, not <td>s of first table.

so, change code from:

table.select("td").iterator(); 

to:

table.select("tr").iterator(); 

that's it!

working example (i added assigning subjects variables):

public static void main(string[] args) throws exception {     // site , parse     document doc = jsoup.connect("http://websemantics.co.uk/tutorials/accessibility_workshop/sessions/session2/03.data_tables/01.simple_data_tables/").get();     // select table     element table = doc.select("table").first();      string math = "";     iterator<element> lines = table.select("tr").iterator();     while (lines.hasnext()) {         element line = lines.next();         system.out.println("text : "+line.text());         if (line.text().contains("mathematics")) {             math = line.text();         }     }      system.out.println("math: "+math); } 

output:

text : subject number of candidates b c d e u text : totals 176 28 37 32 32 25 15 text : mathematics 36 6 7 8 6 5 4 text : english 34 6 8 7 7 5 1 text : chemistry 40 6 9 9 7 5 4 text : physics 36 6 7 8 6 5 4 text : biology 30 4 6 7 6 5 2 math: mathematics 36 6 7 8 6 5 4 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -