title: Save XML from Url and read it
body: <p>I'm making android App and I need to download a <code>xml</code> file from an <code>URL</code> and open it, 
  How I can do this?</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      File dir1 = getDir("xmls",Context.MODE_PRIVATE);//Creating an internal dir;
      System.out.println("dir1: " + dir1);
  
      //Saving The File
      try {
         URL url = new URL("http://www. the url of my xml .xml");
         // The server thinks this request is from an Opera browser!
         String userAgent = "Opera/9.63 (Windows NT 5.1; U; en) Presto/2.1.1";
         System.out.println("Downloading ...");
         downloadFromUrl(url, dir1+"news.xml", userAgent);
         System.out.println("OK");
  } catch (Exception e) {
          System.err.println(e);
          System.out.println("Entri pure nel catch");
      }
      //This is the path of the xml file that i have saved
      URL = dir1+"/news.xml" ; 
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = 
                                         new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      XMLParser parser = new XMLParser();
      String xml = parser.getXmlFromUrl(URL); // getting XML from UR
      Document doc = parser.getDomElement(xml); // getting DOM element
      //And then i do all the parsing
      NodeList nl = doc.getElementsByTagName(KEY_CATEGORIA);
  </code></pre>
  
  <p>And the <code>XMlParser</code> Class is like this:</p>
  
  <pre><code>public class XMLParser_Categorie {
  
  // constructor
  public XMLParser_Categorie() {
  
  }
  
  /**
   * Getting XML from URL making HTTP request
   * @param url string
   * */
  public String getXmlFromUrl(String url) {
      String xml = null;
  
      try {
          // defaultHttpClient
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url);
  
          HttpResponse httpResponse = httpClient.execute(httpPost);
          HttpEntity httpEntity = httpResponse.getEntity();
          xml = EntityUtils.toString(httpEntity);
  
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (ClientProtocolException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      // return XML
      return xml;
  }
  </code></pre>
  
  <p>I need to change this instruction:</p>
  
  <pre><code> DefaultHttpClient httpClient = new DefaultHttpClient();
   HttpPost httpPost = new HttpPost(url);
   HttpResponse httpResponse = httpClient.execute(httpPost);
   HttpEntity httpEntity = httpResponse.getEntity();
   xml = EntityUtils.toString(httpEntity);
  </code></pre>
  
  <p>It a request from a local directory and non an http request.</p>