0

How to parse a soap xml by using touch XML this is soap xml string:

<?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><seach_seriResponse xmlns=\"http://tempuri.org/\"><seach_seriResult><string>abc</string><string>def</string><string>ghi</string></seach_seriResult></seach_seriResponse></soap:Body></soap:Envelope>

I need an array with "string" items

Tuyenp
  • 81
  • 1
  • 11

1 Answers1

0

More or less like this:

NSData* XMLData = ... (assuming you have your XML in an NSData)

CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:XMLData options:0 error:nil] autorelease];

NSMutableDictionary *mappings = [NSMutableDictionary dictionary];
[mappings setObject:@"http://schemas.xmlsoap.org/soap/envelope/" forKey:"soap"];
[mappings setObject:@"http://tempuri.org/" forKey:"tempuri"];

NSArray *nodes = [doc nodesForXPath:@"//soap:Envelope/soap:Body/tempuri:search_seriResponse/tempuri:string" namespaceMappings:mappings error:&err];
Rudi Angela
  • 1,463
  • 1
  • 12
  • 20