[英]App crashing while taking values from XML
I am trying to get url and thumb from the xml by webservice. 我正在尝试通过webservice从xml获取url和thumb。 I am getting the xml but it is crashing while processing the xml.
我正在获取xml,但是在处理xml时崩溃了。
This is my code: 这是我的代码:
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();
}
I myself have exprerienced many times. 我自己经历了很多次。 when u make any change in the xml and just build your project and run it the app crashes.
当您在xml中进行任何更改并仅构建您的项目并运行它时,应用程序崩溃。 If you clean your code instead of building it your problem of crash should get resolved.
如果您清理代码而不是构建代码,则崩溃问题应得到解决。
尝试使用SAX Parser ...,它更易于使用且速度更快,也可能解决了您的问题.. http://www.java-samples.com/showtutorial.php?tutorialid=152
ok i have resolved the problem. 好的,我已经解决了问题。 It was an XML oriented problem.
这是一个面向XML的问题。
Thanks everyone for all help and comments :) 感谢大家的所有帮助和评论:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.