/* * This method is called everytime an end element is found (a closing XML marker) * here we check what element is being closed, if it is a relevant leaf node that we are * checking, such as Title, then we get the characters we have accumulated in the StringBuffer * and set the current Article's title to the value * * If this is closing the "entry", it means it is the end of the article, so we add that to the list * and then reset our Article object for the next one on the stream * * * (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String uri, String localName, String qName) throws SAXException { if (localName.equalsIgnoreCase("title")) { currentArticle.setTitle(chars.toString()); } else if (localName.equalsIgnoreCase("description")) { currentArticle.setDescription(chars.toString()); } else if (localName.equalsIgnoreCase("pubDate")) { currentArticle.setPubDate(chars.toString()); } else if (localName.equalsIgnoreCase("guid")) { currentArticle.setGuid(chars.toString()); } else if (localName.equalsIgnoreCase("creator")) { currentArticle.setAuthor(chars.toString()); } else if (localName.equalsIgnoreCase("encoded")) { currentArticle.setEncodedContent(chars.toString()); } else if (localName.equalsIgnoreCase("item")) { } // Check if looking for article, and if article is complete if (localName.equalsIgnoreCase("item")) { articleList.add(currentArticle); currentArticle = new Article(); // Lets check if we've hit our limit on number of articles articlesAdded++; if (articlesAdded >= ARTICLES_LIMIT) { throw new SAXException(); } } }