Hilfsklassen zum RSS-Auslesen
[yacyandroid:yacyandroid.git] / src / net / yacy / rss / RSSFeedParser.java
1 package net.yacy.rss;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.net.MalformedURLException;
6 import java.net.URL;
7
8 import javax.xml.parsers.ParserConfigurationException;
9 import javax.xml.parsers.SAXParser;
10 import javax.xml.parsers.SAXParserFactory;
11
12 import org.xml.sax.SAXException;
13 import org.xml.sax.XMLReader;
14 import org.xml.sax.helpers.DefaultHandler;
15
16
17
18 public class RSSFeedParser extends DefaultHandler
19 {
20         static final String TITLE = "title";
21         static final String DESCRIPTION = "description";
22         static final String CHANNEL = "channel";
23         static final String LANGUAGE = "language";
24         static final String COPYRIGHT = "copyright";
25         static final String LINK = "link";
26         static final String AUTHOR = "author";
27         static final String ITEM = "item";
28         static final String PUB_DATE = "pubDate";
29         static final String GUID = "guid";
30
31
32         @SuppressWarnings("null")
33         public Feed readFeed(String rss) 
34         {
35                 Feed feed = null;
36                 boolean isFeedHeader = true;
37                 // Set header values intial to the empty string
38                 String description = "";
39                 String title = "";
40                 String link = "";
41                 String language = "";
42                 String copyright = "";
43                 String author = "";
44                 String pubdate = "";
45                 String guid = "";
46                 SAXParserFactory spf = SAXParserFactory.newInstance();
47         SAXParser sp;
48         XMLReader xr;
49                 
50         try
51                 {
52                         sp = spf.newSAXParser();
53                         xr = sp.getXMLReader();
54                 }
55                 catch (ParserConfigurationException e)
56                 {
57                         // TODO Auto-generated catch block
58                         e.printStackTrace();
59                 }
60                 catch (SAXException e)
61                 {
62                         // TODO Auto-generated catch block
63                         e.printStackTrace();
64                 }
65                 
66                 return feed;
67
68         }
69
70 }