【发布时间】:2014-08-01 06:59:22
【问题描述】:
我是 iOS 新手,所以请回答这个幼稚的问题。所以我正在尝试使用.net web 服务。我能够从 Web 服务获取响应,响应如下所示
<?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><getDoctorListResponse
xmlns="http://tempuri.org/"><getDoctorListResult>
[
{
"Zone": "CENTRAL NORTH",
"DoctorName": "Dr Ang Kiam Hwee",
},
{
"Zone": "CENTRAL",
"DoctorName": "Dr Lee Eng Seng",
}
]
</getDoctorListResult>
</getDoctorListResponse>
</soap:Body>
</soap:Envelope>
通过下面的代码,我可以得到唯一的 json
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if ([currentElement isEqualToString:@"getDoctorListResult"]) {
NSDictionary *dc = (NSDictionary *) string;
NSLog(@"Dictionary is = \n%@", dc);
}
}
看起来像json的变量dc等于
[
{
"Zone": "CENTRAL NORTH",
"DoctorName": "Dr Ang Kiam Hwee",
},
{
"Zone": "CENTRAL",
"DoctorName": "Dr Lee Eng Seng",
}
]
我检查了许多类似的问题,例如Xcode how to parse Json Objects、json parsing+iphone 和其他类似问题,但无法解决我的问题。
如何获取 Zone 和 DoctorName 的值并将其存储在 Array 中,然后在 TableView 中显示?
【问题讨论】: