title: How can I fix a unexpected End of Document Exception
body: <p>I saw the other posts on this site and others but people have solved this different ways and none of them required an authentication to access the XML. </p>
  
  <pre><code>DefaultHttpClient httpclient = new DefaultHttpClient();
  HttpGet httpGet = new HttpGet("some web site");
  httpGet.addHeader("Authorization", getAuthHeader());
  HttpResponse response = httpclient.execute(httpGet);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();  
  
  Document doc = db.parse(response.getEntity().getContent());
  
  NodeList nodelst = doc.getElementsByTagName("ad");
  </code></pre>
  
  <p>I know that my HTTP request is fine; its status is 200, but I get this  </p>
  
  <pre><code>saxParserException: unexpected end of document
  </code></pre>
  
  <p>at the line that I have spaced out. Does anyone know how to start from the begining or am I getting a blank file... how can I test for that?</p>
  
  <p>Thanks for your help  </p>
  
  <p>the XML looks like this. it is pretty simple  </p>
  
  <pre><code>&lt;ads&gt;
  &lt;ad&gt;
  &lt;id&gt;6&lt;/id&gt;
  &lt;minViews&gt;10&lt;/minViews&gt;
  &lt;duration&gt;4&lt;/duration&gt;
  &lt;actionUrl&gt;
  some url
  &lt;/actionUrl&gt;
  &lt;imageUrl&gt;
  some url
  &lt;/imageUrl&gt;
  &lt;impressionCount&gt;0&lt;/impressionCount&gt;
  &lt;/ad&gt;
  &lt;/ads&gt;
  </code></pre>