Iphone 如何在soap响应中使用nsxml解析

Iphone 如何在soap响应中使用nsxml解析,iphone,objective-c,Iphone,Objective C,我想解析photoid,我该怎么做呢。我的soap回答是: 2011-08-01 13:14:45.088 SoapSampleApps[1615:207] DONE. Received Bytes: 666 2011-08-01 13:14:45.089 SoapSampleApps[1615:207] <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="h

我想解析photoid,我该怎么做呢。我的soap回答是:

2011-08-01 13:14:45.088 SoapSampleApps[1615:207] DONE. Received Bytes: 666
2011-08-01 13:14:45.089 SoapSampleApps[1615:207] <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:GetTopPicIdsResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"><status xsi:type="xsd:boolean">true</status><message xsi:type="xsd:string">Success</message><photoids xsi:type="xsd:string">9,8,20,21,22,23,24,25,26,19</photoids></ns1:GetTopPicIdsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

使用简单字典对象解析SOAP响应:

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
    self.startelement = elementName;

}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
   [dictionary setObject:string forKey:self.startelement];
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{   
}
您可以从字典中获取值,如

NSString *photoids = [dictionary objectForKey:@"photoids"];
NSString *photoids = [dictionary objectForKey:@"photoids"];