Je veux analyser ce xml et obtenir le résultat entre l'étiquette ... mais je ne peux pas obtenir le résultat de mon xml estErreur dans l'analyseur
<?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>
Le gestionnaire
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;
}
}
}
Toute modification nécessaire
Vos mots-clés peut-être tort. Nsxmlparser n'est-il pas la classe iPhone? Je recommanderais "sax" et "xmlparser" pour cela. –
@Tim ses balises xmlparser sry ... sont corrects .. – xydev