title: Final result in XML feed class is wrong
body: <p>So im trying to create a XML feed program for petrol prices however i believe there to be som error in the class as rather than have the correct result shown which is the URL XML feed of my choice im getting the error message suggesting something has went wrong. Here is my class</p>
  
  <pre><code>package org.me.myandroidstuff;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.net.URLConnection;
  
  //import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.TextView;
  
  public class PetrolPriceActivity extends Menu 
  {
      private TextView response;
      private TextView errorText;
      private String result;
      private String petrolPriceURL;
      private static final String TAG = "PetrolPrice";
      /** Called when the activity is first created. */
      @Override
  
      public void onCreate(Bundle savedInstanceState) 
      {
  
          response = (TextView)findViewById(R.id.title);
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.list);
  
          Bundle extras = getIntent().getExtras();
          if(extras!=null){
          petrolPriceURL =extras.getString("URLString");
          }
          Log.v(TAG, "index=" + petrolPriceURL);
  
          // Get the TextView object on which to display the results
  
  
          try
          {
              // Get the data from the RSS stream as a string
              result =  petrolPriceString(petrolPriceURL);
  
              // Do some processing of the data to get the individual parts of the RSS stream
              // At some point put this processing into a separate thread of execution
              // Display the string in the TextView object just to demonstrate this capability
              // This will need to be removed at some point
              response.setText(result);
          }
          catch(Exception ae)
          {
               //Handle error
              response = (TextView)findViewById(R.id.title);
              response.setText("Error");
               //Add error info to log for diagnostics
          } 
  
      }
  
      // End of onCreate
  
      // Method to handle the reading of the data from the RSS stream
      private static String petrolPriceString(String urlString)throws IOException
      {
          String result = "";
          InputStream anInStream = null;
          int response = -1;
          URL url = new URL(urlString);
          URLConnection conn = url.openConnection();
  
          // Check that the connection can be opened
          if (!(conn instanceof HttpURLConnection))
                  throw new IOException("Not an HTTP connection");
          try
          {
              // Open connection
              HttpURLConnection httpConn = (HttpURLConnection) conn;
              httpConn.setAllowUserInteraction(false);
              httpConn.setInstanceFollowRedirects(true);
              httpConn.setRequestMethod("GET");
              httpConn.connect();
              response = httpConn.getResponseCode();
              // Check that connection is Ok
              if (response == HttpURLConnection.HTTP_OK)
              {
                  // Connection is OK so open a reader 
                  anInStream = httpConn.getInputStream();
                  InputStreamReader in= new InputStreamReader(anInStream);
                  BufferedReader bin= new BufferedReader(in);
  
                  // Read in the data from the RSS stream
                  String line = new String();
                  while (( (line = bin.readLine())) != null)
                  {
                      result = result + "\n" + line;
                  }
              }
          }
          catch (Exception ex)
          {
                  throw new IOException("Error connecting");
          }
  
          // Return result as a string for further processing
          return result;
      }
      // End of petrolPriceString
   // End of Activity class
  }
  </code></pre>
  
  <p>my log shows me in my logcat that the correct URL has been successfully passed from my other class areaURL however when i run the application it isnt correct. Any help would be appreciated as i cant find out what is wrong. Thanks</p>
  
  <p>Here is my logcat to show the URL is correct</p>
  
  <pre><code>08-11 14:47:07.750: D/dalvikvm(889): GC_FOR_ALLOC freed 51K, 5% free 2943K/3076K, paused 37ms, total 39ms
  08-11 14:47:07.760: I/dalvikvm-heap(889): Grow heap (frag case) to 3.553MB for 635812-byte allocation
  08-11 14:47:07.950: D/dalvikvm(889): GC_FOR_ALLOC freed 0K, 4% free 3564K/3700K, paused 33ms, total 33ms
  08-11 14:47:08.400: D/dalvikvm(889): GC_FOR_ALLOC freed &lt;1K, 4% free 3569K/3700K, paused 25ms, total 26ms
  08-11 14:47:08.430: I/dalvikvm-heap(889): Grow heap (frag case) to 7.220MB for 3840016-byte allocation
  08-11 14:47:08.870: D/dalvikvm(889): GC_FOR_ALLOC freed 2K, 2% free 7316K/7452K, paused 187ms, total 187ms
  08-11 14:47:09.430: I/Choreographer(889): Skipped 58 frames!  The application may be doing too much work on its main thread.
  08-11 14:47:09.450: D/gralloc_goldfish(889): Emulator without GPU emulation detected.
  08-11 14:47:11.690: I/Choreographer(889): Skipped 163 frames!  The application may be doing too much work on its main thread.
  08-11 14:48:04.135: I/Choreographer(889): Skipped 43 frames!  The application may be doing too much work on its main thread.
  08-11 14:48:16.055: I/Choreographer(889): Skipped 47 frames!  The application may be doing too much work on its main thread.
  08-11 14:48:17.525: V/AreaURL(889): index=http://www.petrolprices.com/feeds/averages.xml?search_type=town&amp;search_value=Glasgow
  08-11 14:48:17.755: I/Choreographer(889): Skipped 67 frames!  The application may be doing too much work on its main thread.
  08-11 14:48:18.615: V/PetrolPrice(889): index=http://www.petrolprices.com/feeds/averages.xml?search_type=town&amp;search_value=Glasgow
  08-11 14:48:20.215: I/Choreographer(889): Skipped 146 frames!  The application may be doing too much work on its main thread.
  </code></pre>