The problem is in the method readFeed
, and it should be:
private List<Item> readFeed(XmlPullParser parser) throws IOException, XmlPullParserException {
List<Item> items = new ArrayList();
parser.require(XmlPullParser.START_TAG, null, "rss"); // first start tag begin with <rss>
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "channel");// second is <channel>
while (parser.next() != XmlPullParser.END_TAG) { // if encounter </channel>, stop
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
Log.d(TAG, "start tag: " + name);
// Starts by looking for the item tag
if (name.equals("item")) {
items.add(readItem(parser));
} else {
skipTag(parser);
}
}
return items;
}