|
|
@ -29,18 +29,12 @@ public class FeedParser { |
|
|
|
this.callback = callback; |
|
|
|
} |
|
|
|
|
|
|
|
FeedParser(String inputXML) { |
|
|
|
this.inputXML = inputXML; |
|
|
|
} |
|
|
|
FeedParser() {} |
|
|
|
|
|
|
|
// static NewsItemList.Group parsedItem;
|
|
|
|
// static void getParsedItem(String title, String description, String link, String date) {
|
|
|
|
// parsedItem = new NewsItemList().new Group(title, description, date);
|
|
|
|
// this.callback.contentDispatcher();
|
|
|
|
// }
|
|
|
|
|
|
|
|
void parseXML() { |
|
|
|
void parseXML(String inputXML) { |
|
|
|
try { |
|
|
|
this.inputXML = inputXML; |
|
|
|
SAXParserFactory factory = SAXParserFactory.newInstance(); |
|
|
|
SAXParser parser = factory.newSAXParser(); |
|
|
|
ExtendedHandler handler = new ExtendedHandler(); |
|
|
@ -64,6 +58,22 @@ public class FeedParser { |
|
|
|
return Line; |
|
|
|
} |
|
|
|
|
|
|
|
public String getImageLink(String Line){ |
|
|
|
String a = "<img src=\""; |
|
|
|
String b = "\" border=\"0\""; |
|
|
|
Line = Line.substring(Line.indexOf(a)+ a.length()); |
|
|
|
Line = Line.substring(0, Line.indexOf(b)); |
|
|
|
return Line; |
|
|
|
} |
|
|
|
|
|
|
|
public String getDescriptionShort(String Line){ |
|
|
|
String a = "<div class=\"K2FeedIntroText\">"; |
|
|
|
String b = "</div>"; |
|
|
|
Line = Line.substring(Line.indexOf(a)+ a.length()); |
|
|
|
Line = Line.substring(0, Line.indexOf(b)); |
|
|
|
return deleteHtmlTag(Line, "<", ">"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class ExtendedHandler extends DefaultHandler { |
|
|
|
boolean item = false; |
|
|
@ -116,8 +126,9 @@ public class FeedParser { |
|
|
|
public void endElement(String uri, String localName, String qName) throws SAXException { |
|
|
|
if (qName.equalsIgnoreCase("item") && item) { |
|
|
|
item = false; |
|
|
|
descriptionStr = deleteHtmlTag(descriptionStr, "<", ">"); |
|
|
|
callback.contentDispatcher(titleStr, descriptionStr, ""); |
|
|
|
String imageLink = getImageLink(descriptionStr); |
|
|
|
descriptionStr = getDescriptionShort(descriptionStr); |
|
|
|
callback.contentDispatcher(titleStr, descriptionStr, imageLink); |
|
|
|
refreshStrings(); |
|
|
|
} |
|
|
|
} |
|
|
|