Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

more accurate parsing

  • Loading branch information...
commit 220bae5e8d7e072d7694530432b999f4455a4276 1 parent 28a2c67
authored
BIN  RSSReader.jar
Binary file not shown
65  src/org/free2talk/sax/rssreader/RSSHandler.java
@@ -12,6 +12,7 @@
12 12
 	boolean bFoundChannel = false;
13 13
 	int depth = 0;
14 14
 	int currentstate = 0;
  15
+	StringBuffer str;
15 16
 	
16 17
 	/*
17 18
 	* Constructor
@@ -40,6 +41,7 @@ public void endDocument() throws SAXException {
40 41
 	
41 42
 	public void startElement(String namespaceURI, String localName,String qName, Attributes atts) throws SAXException {
42 43
 		depth++;
  44
+		str = new StringBuffer("");
43 45
 		
44 46
 		if (localName.equals("channel")) {
45 47
 			currentstate = 0;
@@ -96,39 +98,40 @@ public void endElement(String namespaceURI, String localName, String qName) thro
96 98
 			feed.addItem(item);
97 99
 			return;
98 100
 		}
  101
+		else {
  102
+			switch (currentstate)
  103
+			{
  104
+				case RSSConstants.ITEM_TITLE:
  105
+					item.setTitle(str.toString());
  106
+					currentstate = 0;
  107
+					break;
  108
+				case RSSConstants.ITEM_AUTHOR:
  109
+					item.setAuthor(str.toString());
  110
+					currentstate = 0;
  111
+					break;
  112
+				case RSSConstants.ITEM_CATEGORY:
  113
+					item.setCategory(str.toString());
  114
+					currentstate = 0;
  115
+					break;
  116
+				case RSSConstants.ITEM_LINK:
  117
+					item.setLink(str.toString());
  118
+					currentstate = 0;
  119
+					break;
  120
+				case RSSConstants.ITEM_DESCRIPTION:
  121
+					item.setDescription(str.toString());
  122
+					currentstate = 0;
  123
+					break;
  124
+				case RSSConstants.ITEM_PUBDATE:
  125
+					item.setPubDate(str.toString());
  126
+					currentstate = 0;
  127
+					break;
  128
+				default:
  129
+					return;
  130
+			}
  131
+		}
99 132
 	}
100 133
 	
101 134
 	public void characters(char ch[], int start, int length) {
102  
-		String theString = new String(ch,start,length);
103  
-		
104  
-		switch (currentstate)
105  
-		{
106  
-			case RSSConstants.ITEM_TITLE:
107  
-				item.setTitle(theString);
108  
-				currentstate = 0;
109  
-				break;
110  
-			case RSSConstants.ITEM_AUTHOR:
111  
-				item.setAuthor(theString);
112  
-				currentstate = 0;
113  
-				break;
114  
-			case RSSConstants.ITEM_CATEGORY:
115  
-				item.setCategory(theString);
116  
-				currentstate = 0;
117  
-				break;
118  
-			case RSSConstants.ITEM_LINK:
119  
-				item.setLink(theString);
120  
-				currentstate = 0;
121  
-				break;
122  
-			case RSSConstants.ITEM_DESCRIPTION:
123  
-				item.setDescription(theString);
124  
-				currentstate = 0;
125  
-				break;
126  
-			case RSSConstants.ITEM_PUBDATE:
127  
-				item.setPubDate(theString);
128  
-				currentstate = 0;
129  
-				break;
130  
-			default:
131  
-				return;
132  
-		}
  135
+		str.append(new String(ch,start,length));
133 136
 	}
134 137
 }

0 notes on commit 220bae5

Please sign in to comment.
Something went wrong with that request. Please try again.