我要分析此XML,并取得标签之间的结果......但我不能得到的结果我的XML是错误解析器
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><loginResponse xmlns="https://comm1.get.com/"><loginResult>true</loginResult><result>success</result></loginResponse></soap:Body></soap:Envelope>
处理程序
public class MyXmlContentHandler extends DefaultHandler {
String result;
private String currentNode;
private String currentValue = null;
public String getFavicon() {
return result;
}
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if (localName.equalsIgnoreCase("result")) {
//offerList = new BFOfferList();
this.result = new String();
}
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
if (localName.equalsIgnoreCase("result")) {
result = localName;
}
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
String value = new String(ch, start, length);
if (currentNode.equals("result")){
result = value;
return;
}
}
}
任何更改需要
你的标签可能是错误的。 iPhone类不是nsxmlparser吗?我会为此推荐“sax”和“xmlparser”。 – 2010-11-26 09:08:16
@Tim它的xmlparser sry ...标签是正确的。 – xydev 2010-11-26 09:11:35