public static UpdateInfo getUpdateInfos(InputStream is)
{
try
{
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 ("path".equals(parser.getName()))
{
String path = parser.nextText();
info.setApkurl(path);
}
break;
}
type = parser.next();
}
return info;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}Xml 解析 PullParser,布布扣,bubuko.com
原文地址:http://blog.csdn.net/feecooling/article/details/38492271