Note that there are some explanatory texts on larger screens.

plurals
  1. POReading from the nasa feed rss file throws SAXException
    text
    copied!<p>I am trying to use the simple-framework in android to read a file which I take from the nasa feed. The nasa file is here: <a href="http://www.nasa.gov/rss/dyn/image_of_the_day.rss" rel="nofollow">http://www.nasa.gov/rss/dyn/image_of_the_day.rss</a></p> <p>The way I go around this is by using the following code:</p> <pre><code>Serializer serialezr = new Persister(); String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/nasa"; try{ File dir = new File(file_path); if(!dir.exists()) { dir.mkdirs(); } File nasa = new File(file_path,filename); if(nasa.exists()) { nasa.delete(); } nasa.createNewFile(); source = new File(file_path + "/" + filename); } catch(Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); view.setText(sw.toString() + "here"); } </code></pre> <p>The above code creates the nasa.xml file in a directory which I will later use</p> <pre><code> DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://www.nasa.gov/rss/dyn/image_of_the_day.rss"); HttpResponse response = httpclient.execute(httpget); HttpEntity ht = response.getEntity(); BufferedHttpEntity buf = new BufferedHttpEntity(ht); InputStream is = buf.getContent(); BufferedReader r = new BufferedReader(new InputStreamReader(is)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line + "\n"); } FileUtils.writeStringToFile(source,total.toString()); </code></pre> <p>The above code actually gets the file from their website using a DefaultHttpClient.</p> <p>"Googling" this I have discovered that the xml file might not be written properly? Looking at the xml file from nasa I cannot see any "&lt;>" tags which appeared to be the most common error that throws this exception. </p> <p><strong>UPDATES</strong></p> <ul> <li>Instead of using BufferedReader and appending a line after a line I have used InputStreamReader to read each character. It runs out of memory</li> <li>Looks like if I take out the ImageView from the layout everything works even the xml parsing.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload