java - JSOUP - doc cannot be resolved and doc cannot be resolved to a variable -


i'm attempting implement jsoup query i'm getting error stating "doc cannot resolved" , "doc cannot resolved variable" know i'll need call doc before can use i'm not sure how yet - it's first time building parser jsoup - i'm sure it's pretty simple - need quick pointer.

public class mainactivity extends activity {       textview tv;     string url = "http://microsoft.com"; string tr;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          tv = (textview) findviewbyid(r.id.textview01);         new mytask().execute(url);     }      private class mytask extends asynctask<string, void, string> {         progressdialog prog;         string title = "";          @override         protected void onpreexecute() {             prog = new progressdialog(mainactivity.this);             prog.setmessage("loading....");             prog.show();         }          @override         protected string doinbackground(string... params) {              try {                     doc = jsoup.connect(params[0]).get();                     element tableelement = doc.select(".datagrid").first();                      elements tablerows = tableelement.select("tr");                     (element row : tablerows) {                         elements cells = row.select("td");                         if (cells.size() >0) {                             system.out.println(cells.get(0).text()+"; "+cells.get(1).text()+"; "+cells.get(2).text()+"; "+cells.get(3).text());                         }                     }}   catch (ioexception e) {                 e.printstacktrace();             }             return title;         }             @override         protected void onpostexecute(string result) {             super.onpostexecute(result);             prog.dismiss();             tv.settext(result);         }     } } 

you trying use variable has not been declared. have done with

textview tv; 

you have declare variable doc.

document doc; 

don't forget import following package org.jsoup.nodes.document.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -