简体   繁体   English

目标C-使用touchXML解析SOAP xml字符串

[英]Objective C - Parse SOAP xml string by using touchXML

How to parse a soap xml by using touch XML this is soap xml string: 如何通过使用touch XML解析soap xml,这是soap xml字符串:

<?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 我需要一个包含“字符串”项的数组

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM