我想通過webservice從xml獲取url和thumb。我得到的XML,但它處理XML時崩潰。從XML獲取值時應用程序崩潰
這是我的代碼:
String tmpstr = EntityUtils.toString(response.getEntity());
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(new StringReader(tmpstr));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getName().toString().equals("url")) {
eventType = xpp.nextToken();
if (eventType == XmlPullParser.CDSECT) {
videourl = videourl + xpp.getText() + ",";
}
} else if (xpp.getName().toString().equals("thumb_image")) {
eventType = xpp.nextToken();
if (eventType == XmlPullParser.CDSECT) {
thumbimage = thumbimage + xpp.getText() + ",";
}
}
}
eventType = xpp.next();
}
發佈您的錯誤日誌。 – 2012-01-13 08:04:29