Пример #1
0
 private XmlReader xmlReaderForFeed(String xml) {
   if (!TextUtils.isEmpty(xml)) {
     try {
       InputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
       return new XmlReader(stream, true);
     } catch (Exception exception) {
       exception.printStackTrace();
     }
   }
   return null;
 }
Пример #2
0
  private List<SyndEntry> entriesForFeed(String xml) {
    ArrayList<SyndEntry> entries = new ArrayList<SyndEntry>();
    XmlReader reader = this.xmlReaderForFeed(xml);
    if (reader != null) {
      try {
        SyndFeed feed = new SyndFeedInput().build(reader);

        for (Iterator i = feed.getEntries().iterator(); i.hasNext(); ) {
          entries.add((SyndEntry) i.next());
        }
      } catch (Exception exception) {
        exception.printStackTrace();
      } finally {
        if (reader != null) {
          try {
            reader.close();
          } catch (IOException ioException) {
            ioException.printStackTrace();
          }
        }
      }
    }
    return entries;
  }