【发布时间】:2010-11-26 08:58:46
【问题描述】:
我想解析这个 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;
}
}
}
需要的任何更改
【问题讨论】:
-
您的标签可能有误。 nsxmlparser 不是 iPhone 类吗?我会为此推荐“sax”和“xmlparser”。
-
@Tim 它的 xmlparser sry... 标签是正确的..
标签: android xml-parsing