XmlPullParser

来源:互联网 发布:男生衣服搭配淘宝知乎 编辑:程序博客网 时间:2024/06/05 17:16
public class UpdateInfoParser {
public static UpdateInfo getUpdateInfo(InputStream is) throws Exception{
XmlPullParser parser=Xml.newPullParser();
parser.setInput(is,"utf-8");
int type= parser.getEventType();
UpdateInfo info=new UpdateInfo();
while (type!=XmlPullParser.END_DOCUMENT) {
switch (type) {
case XmlPullParser.START_TAG:
if ("version".equals(parser.getName())) {
String version=parser.nextText();
info.setVersion(version);
}else if ("description".equals(parser.getName())) {
String description=parser.nextText();
info.setDescription(description);
}else if ("apkurl".equals(parser.getName())) {
String apkurl=parser.nextText();
info.setApkurl(apkurl);
}
break;


}

type=parser.next();

}
return info;




}


}
0 0
原创粉丝点击