public ArrayList<TilterBean> getAuther(InputStream inputStream) {
ArrayList<TilterBean> arrayList = new ArrayList<TilterBean>();
try {
XmlPullParser newPullParser = Xml.newPullParser();
newPullParser.setInput(inputStream, "utf-8");
int eventType = newPullParser.getEventType();
while (eventType != newPullParser.END_DOCUMENT) {
String name = newPullParser.getName();
switch (eventType) {
case XmlPullParser.START_TAG:
if ("news".equals(name)) {
tilterBean = new TilterBean();
} else if ("id".equals(name)) {
tilterBean.setId(Integer.parseInt(newPullParser
.nextText()));
} else if ("title".equals(name)) {
tilterBean.setTitle(newPullParser.nextText());
ArrayList<TilterBean> arrayList = new ArrayList<TilterBean>();
try {
XmlPullParser newPullParser = Xml.newPullParser();
newPullParser.setInput(inputStream, "utf-8");
int eventType = newPullParser.getEventType();
while (eventType != newPullParser.END_DOCUMENT) {
String name = newPullParser.getName();
switch (eventType) {
case XmlPullParser.START_TAG:
if ("news".equals(name)) {
tilterBean = new TilterBean();
} else if ("id".equals(name)) {
tilterBean.setId(Integer.parseInt(newPullParser
.nextText()));
} else if ("title".equals(name)) {
tilterBean.setTitle(newPullParser.nextText());
} else if ("body".equals(name)) {
tilterBean.setBody(newPullParser.nextText());
} else if ("author".equals(name)) {
tilterBean.setAuther(newPullParser.nextText());
} else if ("pubDate".equals(name)) {
tilterBean.setPubDate(newPullParser.nextText());
} else if ("commentCount".equals(name)) {
tilterBean.setCommentCount(newPullParser.nextText());
}
tilterBean.setBody(newPullParser.nextText());
} else if ("author".equals(name)) {
tilterBean.setAuther(newPullParser.nextText());
} else if ("pubDate".equals(name)) {
tilterBean.setPubDate(newPullParser.nextText());
} else if ("commentCount".equals(name)) {
tilterBean.setCommentCount(newPullParser.nextText());
}
break;
case XmlPullParser.END_TAG:
if ("news".equals(name)) {
arrayList.add(tilterBean);
tilterBean = null;
}
break;
case XmlPullParser.END_TAG:
if ("news".equals(name)) {
arrayList.add(tilterBean);
tilterBean = null;
}
break;
default:
break;
}
eventType = newPullParser.next();
}
break;
}
eventType = newPullParser.next();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated catch block
e.printStackTrace();
}
return arrayList;
}
}