-2

Possible Duplicate:
How to get text from this html page with jsoup?

I am trying to parse the images and text from this HTML page using JSOUP.

http://movies.ign.com/articles/100/1002569p1.html

Here is the code i am trying to use to retreive it. But i get nothing returned into the TextView.

The "Doc" Log is logging things from the html page, so its connecting. Im just not receiving any text for some reason.

public class HtmlparserExampleActivity extends Activity {
String outputtext;
  TagFindingVisitor visitor;
  Parser parser = null;
private static final String TAG = "TVGuide";



TextView outputTextView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    outputTextView = (TextView)findViewById(R.id.outputTextView);
    String id = "main-article-content";
    Document doc = null;

    try {
        doc = Jsoup.connect("http://movies.ign.com/articles/100/1002569p1.html").get();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Log.i("DOC", doc.toString().toString());
    Elements elementsHtml = doc.getElementsByTag(id);  
    String[] temp1 = new String[99];    
    int i =0;
    for(Element element: elementsHtml)
    {
        Log.i("data: ", element.text());
        temp1[1] = element.text();  
        outputTextView.setText(temp1[1]);
        i++;


    }




}
}
Community
  • 1
  • 1
android_king22
  • 759
  • 2
  • 20
  • 36

1 Answers1

0

Try this.May be your page is not loaded in doc before your code is executing

doc=Jsoup.parse(new URL("http://movies.ign.com/articles/100/1002569p1.html"),10000);
Rasel
  • 15,499
  • 6
  • 40
  • 50