Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.duveaux.dekrant;
- import java.net.URLEncoder;
- import org.xml.sax.Attributes;
- import org.xml.sax.SAXException;
- import org.xml.sax.helpers.DefaultHandler;
- public class Feed_XMLHandler extends DefaultHandler {
- Boolean currentElement = false;
- String currentValue = null;
- public static Feed_XMLList sitesList = null;
- public static Feed_XMLList getSitesList() {
- return sitesList;
- }
- public static void setSitesList(Feed_XMLList sitesList) {
- Feed_XMLHandler.sitesList = sitesList;
- }
- /** Called when tag starts ( ex:- <name>AndroidPeople</name>
- * -- <name> )*/
- @Override
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
- currentElement = true;
- if (localName.equals("channel"))
- {
- /** Start */
- sitesList = new Feed_XMLList();
- }
- }
- /** Called when tag closing ( ex:- <name>AndroidPeople</name>
- * -- </name> )*/
- @Override
- public void endElement(String uri, String localName, String qName)
- throws SAXException {
- currentElement = false;
- /** set value */
- if (localName.equalsIgnoreCase("title"))
- sitesList.setName(currentValue);
- else if (localName.equalsIgnoreCase("link"))
- sitesList.setLink(currentValue);
- else if (localName.equalsIgnoreCase("description"))
- sitesList.setDescription(currentValue);
- else if (localName.equalsIgnoreCase("pubdate"))
- sitesList.setDate(currentValue);
- }
- /** Called to get tag characters ( ex:- <name>AndroidPeople</name>
- * -- to get AndroidPeople Character ) */
- @Override
- public void characters(char[] ch, int start, int length)
- throws SAXException {
- if (currentElement) {
- currentValue = new String(ch, start, length);
- currentElement = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement