Extracting a specific text block from a website into Android App
<p>I am developing an Android App which has to extract data from a website and the extracted data will be displayed in a text view in the application</p>

<p>After having tried all the possible ways that i found in the googling and Stackoverflow    i am still unable to process the data and now can any one please do help me ..</p>

<p>Details
Website: <a href="http://www.amrita.edu/campuses/blr/index.php" rel="nofollow">http://www.amrita.edu/campuses/blr/index.php</a></p>

<p>In this website i was looking to extract the data of Featured News block and i was unable to get the data and i was always encountered with an Exception Error... </p>

<p>Here's the code : I have used JSOUP to extract </p>

<pre><code>package out.in;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.select.Elements;
import org.w3c.dom.Document;

import android.app.Activity;
import android.os.Bundle;
import android.sax.Element;
import android.widget.TextView;
import android.widget.Toast;

  public class HtmlExtracterActivity extends Activity {
/** Called when the activity is first created. */


//  url
   static final String URL = "http://www.amrita.edu/campuses/blr/index.php";
@Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);


    try {
        ((TextView)findViewById(R.id.tv)).setText(getdata());
    } 
    catch (Exception ex) {

        ((TextView)findViewById(R.id.tv)).setText("Error");

    }  

 }



  protected String getdata() throws Exception {
        String result = "";
        // get html document structure
        Document document = (Document) Jsoup.connect(URL).get();


        // selector query
        Elements featurednews = ((Elements) document).select("div[class=tabber]");
        // check results
        if(featurednews.size() &gt; 0) {
            int i=0;
            int n=featurednews.size();
            for(i=0;i&lt;n;i++)
            {
            // get value
            result = featurednews.get(i).text();
        }
        }


       // Document doc = (Document) Jsoup.parse(result); 
        // String text = ((Elements) doc).text();


        // return
        return result;
    }
</code></pre>

<p>}</p>

<p>I have given the Internet Permission in the Manifest file 
and </p>

<p>Xml file is as follows</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
&gt;

&lt;TextView android:text=" "

android:id="@+id/tv" android:layout_width="wrap_content"
 android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
 &lt;/LinearLayout&gt;
</code></pre>

<p>I would sincrely Appreciate the needed Help in advance</p>
