Android Xml Parsing Null Pointer Exception
I am trying to parse this xml feeds http://www.billboard.com/rss/charts/hot-100 But whenever I try to read description Tag, it throws NullPointerException. Theres a tag at start of
Solution 1:
You can use RSS FEED LIBRARY DOWNLOAD RSS FEED JAR FILE HERE ----> http://code.google.com/p/superpodder/source/browse/trunk/lib/rsslib4j-0.2.jar?r=3
This way you can parse the data
TextView textView = (TextView) findViewById(R.id.textview);
String feedUrl ="http://www.billboard.com/rss/charts/hot-100"; // RSS means Real Simply SyndicationURL url = new URL(feedUrl);
RSSHandler rsshandler = new RSSHandler();
RSSParser.parseXmlFile(url, rsshandler, false);
RSSChannel rssChannel = rsshandler.getRSSChannel();
String data = rssChannel.getAboutAttribute();
textView.append("\n\n");
textView.append("Attributes: "+data+"\n");
data = rssChannel.getCopyright();
textView.append("Copyright: "+data+"\n");
data = rssChannel.getDescription();
textView.append("Description: "+data+"\n");
data = rssChannel.getDocs();
textView.append("Docs: "+data+"\n");
data = rssChannel.getGenerator();
textView.append("Generator: "+data+"\n");
data = rssChannel.getLanguage();
textView.append("Language: "+data+"\n");
data = rssChannel.getLastBuildDate();
textView.append("LastBuildDate: "+data+"\n");
data = rssChannel.getLink();
textView.append("Link: "+data+"\n");
data = rssChannel.getPubDate();
textView.append("PubDate: "+data+"\n");
data = rssChannel.getTitle();
textView.append("Title: "+data+"\n");
data = rssChannel.getTTL();
textView.append("TTL: "+data+"\n");
data = rssChannel.getWebMaster();
textView.append("WebMaster: "+data+"\n");
RSSImage rssImage = rssChannel.getRSSImage();
data = rssImage.getTitle();
textView.append("ImageTitle: "+data+"\n");
data = rssImage.getWidth();
textView.append("ImageWidth: "+data+"\n");
data = rssImage.getHeight();
textView.append("ImageHeight: "+data+"\n");
data = rssImage.getLink();
textView.append("ImageLink: "+data+"\n");
data = rssImage.getUrl();
textView.append("ImageUrl: "+data+"\n");
textView.append("\n");
LinkedList linkedList = rssChannel.getItems();
int size = linkedList.size();
textView.append("Total Items: "+size+"\n");
Note: This is for only rssfeed Urls do not parse any other url using this library
Solution 2:
Is there any character like "&" or "--" in your XML file?! i figure it out that parser can not parse those! just try to change it if you have one
Post a Comment for "Android Xml Parsing Null Pointer Exception"