public List<Entry> parse() { SAXParserFactory factory = SAXParserFactory.newInstance(); Log.d(AppSettings.TAG_LOG, "parse()"); try { SAXParser parser = factory.newSAXParser(); RssHandler handler = new RssHandler(); parser.parse(new InputSource(this.getInputStream()), handler); return handler.getNoticias(); } catch (Exception e) { throw new RuntimeException(e); } }
public Update parse() { SAXParserFactory factory = SAXParserFactory.newInstance(); InputStream inputStream = this.getInputStream(); if (inputStream != null) { try { SAXParser parser = factory.newSAXParser(); RssHandler handler = new RssHandler(); parser.parse(inputStream, handler); return handler.getUpdate(); } catch (ParserConfigurationException | SAXException e) { Log.e( "AppUpdater", "The XML updater file is mal-formatted. AppUpdate can't check for updates."); return null; } catch (IOException e) { throw new RuntimeException(e); } } else { return null; } }
@Override protected RssFeed doInBackground(URL... url) { RssFeed feed; InputStream stream; try { stream = url[0].openStream(); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); RssHandler handler = new RssHandler(); InputSource input = new InputSource(stream); reader.setContentHandler(handler); reader.parse(input); feed = handler.getResult(); } catch (Exception e) { Log.e( "Error getting feed", "An error occurred while getting the rss feed: " + e.getMessage()); feed = null; } return feed; }