Android RSS Reader cuts off after first pragraph

eboss

New Member
I am creating an app for my school newspaper and am running into a problem when trying to display the full article. Currently I have a list of articles appear that are pulled from an RSS feed, and when one is clicked on it brings up the content of the article. However only the first paragraph displays in the TextView, no matter how long it is. This leads me too believe that it has something to do with the <p></p> HTML tags. I am not that familiar with RSS feeds or parsing XML(this being my first time trying it)and have looked around for ways to do what I'm trying to accomplish.From: Android TextView cuts off after one paragraphI am creating this question based on results of the above question. I thought the problem with my app had something to do with the TextView and it's properties but by using plain text that I hard coded in it operates just fine. Based on the comments and things that I tried, the problem appears to be with how the app is reading information from the RSS feed. Like I said before this is my first time working with RSS feeds in Android, and I am using a sample projects code(can be found in the previous questions). Below is the code relevant to the RSS feed:RSSFeed.java:public class RSSFeed { private String title = null; private String description = null; private String link = null; private String pubdate = null; private String content = null; private List<RSSItem> itemList; RSSFeed(){ itemList = new Vector<RSSItem>(0); } void addItem(RSSItem item){ itemList.add(item); } RSSItem getItem(int location){ return itemList.get(location); } List<RSSItem> getList(){ return itemList; } void setTitle(String value){ title = value; } void setDescription(String value){ description = value; } void setLink(String value){ link = value; } void setPubdate(String value){ pubdate = value; } public void setContent(String value) { content=value; } String getTitle(){ return title; } String getDescription(){ return description; } String getLink(){ return link; } String getPubdate(){ return pubdate; } String getContent() { return content; }}RSSHandler.java:public class RSSHandler extends DefaultHandler {final int state_unknown = 0;final int state_title = 1;final int state_description = 2;final int state_link = 3;final int state_pubdate = 4;final int state_content = 5;int currentState = state_unknown;RSSFeed feed;RSSItem item;boolean itemFound = false;RSSHandler(){}RSSFeed getFeed(){ return feed;}@Overridepublic void startDocument() throws SAXException { // TODO Auto-generated method stub Log.d("RSSHandler.startDocument", "START DOCUMENT"); feed = new RSSFeed(); item = new RSSItem();}@Overridepublic void endDocument() throws SAXException { // TODO Auto-generated method stub Log.d("RSSHandler.endDocument", "END DOCUMENT.");}@Overridepublic void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // TODO Auto-generated method stub Log.d("RSSHandler.startElement", "Item found, BEGIN startElement."); if (localName.equalsIgnoreCase("item")){ itemFound = true; item = new RSSItem(); currentState = state_unknown; Log.d("RSSHandler.startElement", "Item found, state unknown."); } else if (localName.equalsIgnoreCase("title")){ currentState = state_title; Log.d("RSSHandler.startElement", "Item found, state_title."); } else if (localName.equalsIgnoreCase("description")){ currentState = state_description; Log.d("RSSHandler.startElement", "Item found, state_description."); } else if (localName.equalsIgnoreCase("link")){ currentState = state_link; Log.d("RSSHandler.startElement", "Item found, state_link."); } else if (localName.equalsIgnoreCase("pubdate")){ currentState = state_pubdate; Log.d("RSSHandler.startElement", "Item found, state_pubdate."); } else if(localName.equalsIgnoreCase("encoded")){ currentState = state_content; Log.d("RSSHandler.startElement", "Item found, state_encoded."); } else{ currentState = state_unknown; Log.d("RSSHandler.startElement", "Item found, no local name match, state_unknown."); }}@Overridepublic void endElement(String uri, String localName, String qName) throws SAXException { // TODO Auto-generated method stub if (localName.equalsIgnoreCase("item")){ feed.addItem(item); Log.d("RSSHandler.endElement", "item added to feed."); }}@Overridepublic void characters(char[] ch, int start, int length) throws SAXException { // TODO Auto-generated method stub String strCharacters = new String(ch,start,length); if (itemFound==true){// "item" tag found, it's item's parameter Log.d("RSSHandler.characters", "Item found, checking current state."); switch(currentState){ case state_title: item.setTitle(strCharacters); Log.d("RSSHandler.characters", "ITEM TITLE SET, state_title."); break; case state_description: item.setDescription(strCharacters); Log.d("RSSHandler.characters", "ITEM DESCRIPTION SET, state_description."); break; case state_link: item.setLink(strCharacters); Log.d("RSSHandler.characters", "ITEM LINK SET, state_link."); break; case state_pubdate: item.setPubdate(strCharacters); Log.d("RSSHandler.characters", "ITEM PUBDATE, state_pubdate."); break; case state_content: item.setContent(strCharacters); Log.d("RSSHandler.characters", "ITEM CONTENT SET, state_content."); break; default: Log.d("RSSHandler.characters", "ITEM NOT SET, no matching case."); break; } } else{ // not "item" tag found, it's feed's parameter switch(currentState){ case state_title: feed.setTitle(strCharacters); Log.d("RSSHandler.characters", "FEED TITLE SET, state_title."); break; case state_description: feed.setDescription(strCharacters); Log.d("RSSHandler.characters", "FEED DESCRIPTION SET, state_description."); break; case state_link: feed.setLink(strCharacters); Log.d("RSSHandler.characters", "FEED LINK SET, state_link."); break; case state_pubdate: feed.setPubdate(strCharacters); Log.d("RSSHandler.characters", "FEED PUBDATE SET, state_pubdate."); break; case state_content: feed.setContent(strCharacters); Log.d("RSSHandler.characters", "FEED CONTENT SET, state_content."); break; default: Log.d("RSSHandler.characters", "FEED NOT SET, no matching case."); break; } } currentState = state_unknown;}}RSSItem.java:public class RSSItem {private String title = null;private String description = null;private String link = null;private String pubdate = null;private String content = null;RSSItem(){}void setTitle(String value){ title = value;}void setDescription(String value){ description = value;}void setLink(String value){ link = value;}void setPubdate(String value){ pubdate = value;}public void setContent(String value) { content=value;}String getTitle(){ return title;}String getDescription(){ return description;}String getLink(){ return link;}String getPubdate(){ return pubdate;}public String getContent() { return content;}@Overridepublic String toString() { // TODO Auto-generated method stub return title;}}The AllStoriesFragment.java and ShowDetails.java are posted in the other questions, though the code may be slightly different from what I have currently. My issue is still the same, no matter what article or length of the first paragraph, it will always cut off. Any insight is appreciated.
 
Back
Top