0

I need to parse the response XML message from Web Service. The message is like:

<?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><HelloAppleResponse xmlns="http://testest.org/"><HelloAppleResult>StringThatINeed</HelloAppleResult></HelloAppleResponse></soap:Body></soap:Envelope>

Message is in a variable call strData:

var strData = NSString(data: data, encoding: NSUTF8StringEncoding)

I need to use NSXMLParser, but I don't know how to use it.

    // NSXMLParserDelegate

  func parser(parser: NSXMLParser!, didStartElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: NSDictionary!) {
        currentElementName = elementName
    }


func parser(parser: NSXMLParser, foundCharacters string: String?) {
    if currentElementName == "HelloAppleResult" {
        txtResult.text = string
    }
}
Federcio2
  • 89
  • 11

0 Answers0