<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<message xmlns="https://mobile.XXXXXXXX">
<version>4.0</version>
<appVersion>MP_AND_APP_X1_99BILL_01_05_00_15033117_02</appVersion>
<bizType>S110</bizType><responseCode>00</responseCode><responseMsg>成功</responseMsg>
<deviceInfo><mac>81:7a:88:09:97:23</mac><imei>99000291204203</imei><imsi>460031206106299</imsi>
</deviceInfo><userName>12345678910</userName>
<msgContent>
<appInfo><appType>Android</appType>
<latestAppVersion>1.6.0.12</latestAppVersion>
<latestAppVersionUrl>https://XXXXXXXXXX.apk</latestAppVersionUrl>
<appFlag>2</appFlag></appInfo>
</msgContent>
</message>
------解决思路----------------------
public void xml() throws XmlPullParserException, IOException{成功拿到数据
String str = "";
XmlPullParser xmlPullParser= Xml.newPullParser();
xmlPullParser.setInput(getResources().openRawResource(R.raw.file),"UTF-8");
int type=xmlPullParser.getEventType();
while(type!=XmlPullParser.END_DOCUMENT){
switch (type) {
case XmlPullParser.START_DOCUMENT:
{
// updateinfolist =new ArrayList<msgContent>();
}
break;
case XmlPullParser.START_TAG:
String tag=xmlPullParser.getName();
// if(tag.equalsIgnoreCase("appInfo")){
// updateinfo=new msgContent();
// statrtappInfo=true;
// }
if(tag.equalsIgnoreCase("latesAppVersion")){
// updateinfo.setLatestAppVersion(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}else if(tag.equalsIgnoreCase("appVersion")){
// updateinfo.setAppVersion(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}if(tag.equalsIgnoreCase("responseCode")){
// updateinfo.setResponseCode(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}if(tag.equalsIgnoreCase("appFlag")){
// updateinfo.setAppFlag(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}if(tag.equalsIgnoreCase("appType")){
// updateinfo.setAppType(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}if(tag.equalsIgnoreCase("latestAppVersionUrl")){
// updateinfo.setLatestAppVersionUrl(xmlPullParser.getText());
str +="=====" + xmlPullParser.nextText()+";" ;
}
break;
case XmlPullParser.END_TAG:
if(xmlPullParser.getName().equals("appInfo")){
// updateinfolist.add(updateinfo);
// updateinfo=null;
}
}
type=xmlPullParser.next();
}
System.out.print(str);
}
------解决思路----------------------
public void xml(int id) throws XmlPullParserException, IOException{就这样吧他需要的参数传递进去就ok
String str = "";
XmlPullParser xmlPullParser= Xml.newPullParser();
xmlPullParser.setInput(getResources().openRawResource(id),"UTF-8");