<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getMobileCodeInfoResponse xmlns="http://WebXml.com.cn/">
<getMobileCodeInfoResult>中文</getMobileCodeInfoResult>
</getMobileCodeInfoResponse>
</soap:Body>
</soap:Envelope>
解析该xml要获取“中文”我是这么做得:
private static String praseSOAP(InputStream xml) throws Exception {
XmlPullParser parse = Xml.newPullParser();
parse.setInput(xml, "UTF-8");
int event = parse.getEventType();
while (event != XmlPullParser.END_TAG) {
switch (event) {
case XmlPullParser.START_DOCUMENT:
if ("getMobileCodeInfoResult".equals(parse.getName())) {
return parse.nextText();
}
break;
default:
break;
}
event = parse.next();
}
return null;
}刚开始的时候没错,但不出结果,现在就直接出异常了!求大侠帮忙看看哪里出错了,在线等!XML
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getMobileCodeInfoResponse xmlns="http://WebXml.com.cn/">
<getMobileCodeInfoResult>中文</getMobileCodeInfoResult>
</getMobileCodeInfoResponse>
</soap:Body>
</soap:Envelope>
解析该xml要获取“中文”我是这么做得:
private static String praseSOAP(InputStream xml) throws Exception {
XmlPullParser parse = Xml.newPullParser();
parse.setInput(xml, "UTF-8");
int event = parse.getEventType();
while (event != XmlPullParser.END_TAG) {
switch (event) {
case XmlPullParser.START_DOCUMENT:
if ("getMobileCodeInfoResult".equals(parse.getName())) {
return parse.nextText();
}
break;
default:
break;
}
event = parse.next();
}
return null;
}刚开始的时候没错,但不出结果,现在就直接出异常了!求大侠帮忙看看哪里出错了,在线等!XML
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货