title: android parsing Feed RSS images
body: <p>I'm using this library <a href="https://github.com/matshofman/Android-RSS-Reader-Library" rel="nofollow">https://github.com/matshofman/Android-RSS-Reader-Library</a> to parse Feed RSS. I tried to edit it for get also the images but i don't know if I am in the right way and I don't know how to edit RssHandler.java
  The images I want to parse are enclosed in an img Tag.</p>
  
  <p>Thanks for the help!</p>
  
  <p>Here the code:</p>
  
  <p>RssFeed.java</p>
  
  <pre><code>public class RssFeed implements Parcelable {
  
  private String title;
  private String link;
  private String description;
  private String language;
  private String imageUrl;
  private ArrayList&lt;RssItem&gt; rssItems;
  
  public RssFeed() {
      rssItems = new ArrayList&lt;RssItem&gt;();
  }
  
  public RssFeed(Parcel source) {
  
      Bundle data = source.readBundle();
      title = data.getString("title");
      link = data.getString("link");
      description = data.getString("description");
      language = data.getString("language");
      imageUrl = data.getString("imageUrl");
      rssItems = data.getParcelableArrayList("rssItems");
  
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
  
      Bundle data = new Bundle();
      data.putString("title", title);
      data.putString("link", link);
      data.putString("description", description);
      data.putString("language", language);
      data.putString("imageUrl", imageUrl);
      data.putParcelableArrayList("rssItems", rssItems);
      dest.writeBundle(data);
  }
  
  public static final Parcelable.Creator&lt;RssFeed&gt; CREATOR = new Parcelable.Creator&lt;RssFeed&gt;() {
      public RssFeed createFromParcel(Parcel data) {
          return new RssFeed(data);
      }
      public RssFeed[] newArray(int size) {
          return new RssFeed[size];
      }
  };
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  void addRssItem(RssItem rssItem) {
      rssItems.add(rssItem);
  }
  
  public String getTitle() {
      return title;
  }
  
  public void setTitle(String title) {
      this.title = title;
  }
  
  public String getLink() {
      return link;
  }
  
  public void setLink(String link) {
      this.link = link;
  }
  
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  public String getLanguage() {
      return language;
  }
  
  public void setLanguage(String language) {
      this.language = language;
  }
  
  public String getImageUrl() {
      return imageUrl;
  }
  
  public void setImageUrl(String imageUrl) {
      this.imageUrl = imageUrl;
  }
  
  public ArrayList&lt;RssItem&gt; getRssItems() {
      return rssItems;
  }
  
  public void setRssItems(ArrayList&lt;RssItem&gt; rssItems) {
      this.rssItems = rssItems;
  } 
  }
  </code></pre>
  
  <p>RssItem.java</p>
  
  <pre><code>public class RssItem implements Comparable&lt;RssItem&gt;, Parcelable {
  
  private RssFeed feed;
  private String title;
  private String link;
  private Date pubDate;
  private String description;
  private String content;
  private String imageUrl;
  
  public RssItem() {
  
  }
  
  public RssItem(Parcel source) {
  
      Bundle data = source.readBundle();
      title = data.getString("title");
      link = data.getString("link");
      pubDate = (Date) data.getSerializable("pubDate");
      description = data.getString("description");
      content = data.getString("content");
      imageUrl = data.getString("imageUrl");
      feed = data.getParcelable("feed");
  
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
  
      Bundle data = new Bundle();
      data.putString("title", title);
      data.putString("link", link);
      data.putSerializable("pubDate", pubDate);
      data.putString("description", description);
      data.putString("content", content);
      data.putString("imageUrl", imageUrl);
      data.putParcelable("feed", feed);
      dest.writeBundle(data);
  }
  
  public static final Parcelable.Creator&lt;RssItem&gt; CREATOR = new Parcelable.Creator&lt;RssItem&gt;() {
      public RssItem createFromParcel(Parcel data) {
          return new RssItem(data);
      }
      public RssItem[] newArray(int size) {
          return new RssItem[size];
      }
  };
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  public RssFeed getFeed() {
      return feed;
  }
  
  public void setFeed(RssFeed feed) {
      this.feed = feed;
  }
  
  public String getTitle() {
      return title;
  }
  
  public void setTitle(String title) {
      this.title = title;
  }
  
  public String getLink() {
      return link;
  }
  
  public void setLink(String link) {
      this.link = link;
  }
  
  public String getImageUrl() {
      return imageUrl;
  }
  
  public void setImageUrl(String imageUrl) {
      this.imageUrl = imageUrl;
  }
  
  public Date getPubDate() {
      return pubDate;
  }
  
  public void setPubDate(Date pubDate) {
      this.pubDate = pubDate;
  }
  
  public void setPubDate(String pubDate) {
      try {
          SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
          this.pubDate = dateFormat.parse(pubDate);
      } catch (ParseException e) {
          e.printStackTrace();
      }
  }
  
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  public String getContent() {
      return content;
  }
  
  public void setContent(String content) {
      this.content = content;
  }
  
  @Override
  public int compareTo(RssItem another) {
      if(getPubDate() != null &amp;&amp; another.getPubDate() != null) {
          return getPubDate().compareTo(another.getPubDate());
      } else { 
          return 0;
      }
  }
  
  }
  </code></pre>
  
  <p>RssReader.java</p>
  
  <pre><code>public class RssReader {
  
  public static RssFeed read(URL url) throws SAXException, IOException {
  
      return read(url.openStream());
  
  }
  
  public static RssFeed read(InputStream stream) throws SAXException, IOException {
  
      try {
  
          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);
  
          return handler.getResult();
  
      } catch (ParserConfigurationException e) {
          throw new SAXException();
      }
  
  }
  
  }
  </code></pre>
  
  <p>RssHandler.java</p>
  
  <pre><code>public class RssHandler extends DefaultHandler {
  
  private RssFeed rssFeed;
  private RssItem rssItem;
  private StringBuilder stringBuilder;
  
  @Override
  public void startDocument() {
      rssFeed = new RssFeed();
  }
  
  /**
   * Return the parsed RssFeed with it's RssItems
   * @return
   */
  public RssFeed getResult() {
      return rssFeed;
  }
  
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) {
      stringBuilder = new StringBuilder();
  
      if(qName.equals("item") &amp;&amp; rssFeed != null) {
          rssItem = new RssItem();
          rssItem.setFeed(rssFeed);
          rssFeed.addRssItem(rssItem);
      }
  }
  
  @Override
  public void characters(char[] ch, int start, int length) {
      stringBuilder.append(ch, start, length);
  }
  
  @Override
  public void endElement(String uri, String localName, String qName) {
  
      if(rssFeed != null &amp;&amp; rssItem == null) {
          // Parse feed properties
  
          try {
              if (qName != null &amp;&amp; qName.length() &gt; 0) {
                  String methodName = "set" + qName.substring(0, 1).toUpperCase() + qName.substring(1);
                  Method method = rssFeed.getClass().getMethod(methodName, String.class);
                  method.invoke(rssFeed, stringBuilder.toString());
              }
          } catch (SecurityException e) {
          } catch (NoSuchMethodException e) {
          } catch (IllegalArgumentException e) {
          } catch (IllegalAccessException e) {
          } catch (InvocationTargetException e) {
          }
  
      } else if (rssItem != null) {
          // Parse item properties
  
          try {
              if(qName.equals("content:encoded")) 
                  qName = "content";
              String methodName = "set" + qName.substring(0, 1).toUpperCase() + qName.substring(1);
              Method method = rssItem.getClass().getMethod(methodName, String.class);
              method.invoke(rssItem, stringBuilder.toString());
          } catch (SecurityException e) {
          } catch (NoSuchMethodException e) {
          } catch (IllegalArgumentException e) {
          } catch (IllegalAccessException e) {
          } catch (InvocationTargetException e) {
          }
      }
  
  }
  
  }
  </code></pre>