使用 Soap Web 服务解析 Xml [英] Parsing an Xml using Soap Web Services
问题描述
我正在尝试使用教程解析从 Web 服务接收的 xml 文件 肥皂教程
i am trying to parse an xml file that i receive from a web service using the tutorial Soap Tutorial
...
我将接收到的数据初始化为 NSString 如下
i initialize the data received to a NSString as follows
NSString *theXML = [[NSString alloc]
initWithBytes: [webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];
`
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCategoryResponse xmlns="http://tempuri.org/">
<GetCategoryResult>
<Root><Record><catid>1</catid><catname>Hi</catname><catlogo>http://10.25.4.49/monsoonstore/Category/50X50.GIF</catlogo></Record></Root></GetCategoryResult>
</GetCategoryResponse>
</s:Body>
</s:Envelope>
当我解析数据时,我的解析器没有读取 ROOT 标签,而是以 envelope 标签开头.我怎样才能让解析器读取解析我从服务器收到的确切 xml,即
when i parse the data my parser doesn't read the ROOT tag as it should but instead starts with the envelope tag.. how can i get the parser to parse the exact xml that i receive from the server i.e
<Root><Record><catid>1</catid><catname>Hi</catname><catlogo>http://10.25.4.49/monsoonstore/Category/50X50.GIF</catlogo></Record></Root>
我如何使用正确的标签解析这个webData??
how can i parse this webData with te correct tags??
推荐答案
你可以使用TouchXML解析器来获得更好的和想要的结果,然后在XML解析器函数中使用
you may use the TouchXML parser to get better and desired results, and then use in XML parser function
NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease];
CXMLDocument *xmlParser = [[[CXMLDocument alloc] initWithXMLString:responseString options:0 error:nil] autorelease];
NSArray *returnNodes = NULL;
returnNodes = [xmlParser nodesForXPath:@"//Root" error:nil];
.
.
.
这篇关于使用 Soap Web 服务解析 Xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!