Quantcast
Channel: Null Pointer error RSS feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Sam for Null Pointer error RSS feed

$
0
0

I would guess that xpp.getClass() returns null when xpp references the text inside a set of tags. If you look at the example in XmlPullParser's documentation:

 while (eventType != XmlPullParser.END_DOCUMENT) {  if(eventType == XmlPullParser.START_DOCUMENT) {      System.out.println("Start document");  } else if(eventType == XmlPullParser.START_TAG) {      System.out.println("Start tag "+xpp.getName());  } else if(eventType == XmlPullParser.END_TAG) {      System.out.println("End tag "+xpp.getName());  } else if(eventType == XmlPullParser.TEXT) {      System.out.println("Text "+xpp.getText());  }  eventType = xpp.next(); }

Notice that the focus is on the eventType. If you only want to grab "title" and "link" tags, add these checks inside the section for START_TAG:

else if(eventType == XmlPullParser.START_TAG) {    if(xpp.getName().equalsIgnoreCase("title")){        //Get title    }else if(xpp.getName().equalsIgnoreCase("link")){        //Get link    }}

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>