我需要一些帮助来解析这个响应。我认为它是 WSDL 并想检查“成功输入”字符串。下面是代码:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://example.com/reg/abc">
<soapenv:Header/>
<soapenv:Body>
<sch:LoginResponse>
<sch:Status code=200>Successfully Entered</sch:Status>
<sch:Message>[CDATA[Successfully Entered]]</sch:Message>
</sch:LoginResponse>
</soapenv:Body>
</soapenv:Envelope>
编辑:下面是我实现的代码
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
NSLog(@"START ELEMENT NAME ==> %@", elementName);
if( [elementName isEqualToString:@"sch:Status"])
{
if(!soapResults)
{
soapResults = [[NSMutableString alloc] init];
}
elementFound = YES;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if( elementFound )
{
[soapResults appendString:string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
NSLog(@"END ELEMENT NAME ==> %@", elementName);
if( [elementName isEqualToString:@"sch:Status"])
{
NSLog(@"Found ==> %@", soapResults);
[soapResults setString:@""];
elementFound = FALSE;
}
}
打印日志显示 uptosch:LoginResponse
而不是元素名称sch:Status