title: Retrieve RSS feed and display it in text view
body: <p>I would like to get this link " " working.
  I want to retrieve the RSS feed and display it in a text view,</p>
  
  <p>I've tried out the code but doesn't seems to be working.
  I guess there is something wrong with the code but I'm not sure where has it gone wrong.
  I'm new to android.</p>
  
  <p>I need help, please.</p>
  
  <p>Thanks.</p>
  
  <p>Here are my code.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>  public class MainActivity extends Activity {
  
  TextView psi;
  
  class MyWeather{
      String title;
  String description;
  
  
  public String toString(){
  
   return "\n- " 
  
    + "Condition: " + title + "\n"
    + description +"\n";
  
  }
  }
  
   /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      psi = (TextView)findViewById(R.id.psi);
  
  
      new MyAsyncTask().execute();
  }
  
  
       public class MyAsyncTask extends AsyncTask&lt;Void, Void, Void&gt; {
              ProgressDialog dialog;
              MyWeather weatherResult;
  
              @Override
              protected void onPreExecute() {
                  // TODO Auto-generated method stub
                  dialog = new ProgressDialog(MainActivity.this);
                  dialog.setMessage("Please wait...");
                  dialog.show();
                  super.onPreExecute();
              }
  
              @Override
              protected Void doInBackground(Void... params) {
                  String weatherString = QueryYahooWeather();
                  Document weatherDoc = convertStringToDocument(weatherString);
  
                  weatherResult = parseWeather(weatherDoc);
                  Document dest = null;
  
                  DocumentBuilderFactory dbFactory =
                    DocumentBuilderFactory.newInstance();
                  DocumentBuilder parser;
  
                  try {
                   parser = dbFactory.newDocumentBuilder();
                 dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
                } catch (ParserConfigurationException e1) {
                 e1.printStackTrace();
                 Toast.makeText(MainActivity.this,
                     e1.toString(), Toast.LENGTH_LONG).show();
                } catch (SAXException e) {
                 e.printStackTrace();
                 Toast.makeText(MainActivity.this,
                     e.toString(), Toast.LENGTH_LONG).show();
                } catch (IOException e) {
                 e.printStackTrace();
                 Toast.makeText(MainActivity.this,
                     e.toString(), Toast.LENGTH_LONG).show();
                }
  
                  return dest;
                 }
  
              private MyWeather parseWeather(Document weatherDoc) {
                  MyWeather myWeather = new MyWeather();
  
                    //&lt;description&gt;Yahoo! Weather for New York, NY&lt;/description&gt;
                    //myWeather.description = srcDoc.getElementsByTagName("description")
                      //.item(0)
                      //.getTextContent();
  
  
                    Node locationNode = srcDoc.getElementsByTagName("item").item(0);
                    myWeather.title = locationNode.getAttributes()
                    .getNamedItem("title")
                    .getNodeValue()
                    .toString();
                  myWeather.description = locationNode.getAttributes()
                    .getNamedItem("description")
                    .getNodeValue()
                    .toString();
  
                    return myWeather;
                   }
  
              }
  
              }
  
              private Document convertStringToDocument(String weatherString) {
                  // TODO Auto-generated method stub
                  return null;
              }
  
              private String QueryYahooWeather() {
                  // TODO Auto-generated method stub
                  String qResult = "";
                    String queryString = "app2.nea.gov.sg/data/rss/nea_psi.xml";
  
                    HttpClient httpClient = new DefaultHttpClient();
                       HttpGet httpGet = new HttpGet(queryString);
  
                       try {
                        HttpEntity httpEntity = httpClient.execute(httpGet).getEntity();
  
                        if (httpEntity != null){
                         InputStream inputStream = httpEntity.getContent();
                         Reader in = new InputStreamReader(inputStream);
                         BufferedReader bufferedreader = new BufferedReader(in);
                         StringBuilder stringBuilder = new StringBuilder();
  
                         String stringReadLine = null;
  
                         while ((stringReadLine = bufferedreader.readLine()) != null) {
                          stringBuilder.append(stringReadLine + "\n");
                         }
  
                         qResult = stringBuilder.toString();
                        }
  
                  } catch (ClientProtocolException e) {
                   e.printStackTrace();
                   Toast.makeText(MainActivity.this,
                       e.toString(), Toast.LENGTH_LONG).show();
                  } catch (IOException e) {
                   e.printStackTrace();
                   Toast.makeText(MainActivity.this,
                       e.toString(), Toast.LENGTH_LONG).show();
                  }
  
                       return qResult;
  
  
                  }
  
              @Override
              protected void onPostExecute(Void result) {
                  // TODO Auto-generated method stub
  
                  dialog.dismiss();
                  psi.setText(weatherResult.toString());
                  super.onPostExecute(result);
              }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".MainActivity" &gt;
  
  
  
  
  
          &lt;TextView
              android:id="@+id/psi"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>