@Override public void set(String link) { final android.net.Uri uri = android.net.Uri.parse(link); if (item == null) { feed.setLink(uri); } else { item.setLink(uri); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (inChannel) { if (inTitle) { feeds.setTitle(temp); inTitle = false; } else if (inLink) { feeds.setLink(temp); inLink = false; } else if (inDesc) { Document doc = Jsoup.parseBodyFragment(temp); Element body = doc.body(); feeds.setDescription(body.text()); inDesc = false; } else if (inLanguage) { feeds.setLanguage(temp); inLanguage = false; } } else if (inItem) { if (inTitle) { item.setTitle(temp); inTitle = false; } else if (inLink) { item.setLink(temp); inLink = false; } else if (inDesc) { Document doc = Jsoup.parseBodyFragment(temp); Element body = doc.body(); item.setDescription(body.text()); inDesc = false; } else if (inPubdate) { item.setPubdate(temp); inPubdate = false; } else if (inGuid) { item.setGuid(temp); inGuid = false; } } if (qName.equalsIgnoreCase("channel")) { if (feeds != null) { feeds.setItems(itemsList); feedsList.add(feeds); itemsList = new ArrayList<RSSItem>(); } } if (qName.equalsIgnoreCase("item")) { if (item != null) itemsList.add(item); } }
/** * When parsing this RSS XML document, this indicates the body of an XML tag * * @param qname * @param chars * @param attributes */ protected synchronized void parseElement( final String qname, final String chars, final XMLAttributes attributes) { try { if (currentItem != null) { synchronized (currentItem) { if (qname.equals("title")) { currentItem.setTitle(chars); } else if (qname.equals("description")) { currentItem.setDescription(chars); } else if (qname.equals("link")) { currentItem.setLink(chars); } else if (qname.equals("pubDate")) { currentItem.setPubDate(chars); } else if (qname.equals("media:thumbnail")) { currentItem.setThumbnail((String) attributes.getValue("url")); } } } } catch (Exception e) { // #debug L.e("RSS parsing error", "qname=" + qname + " - chars=" + chars, e); } }