我需要创建一个NSString
xml 格式的文件,以便将其作为 Web 服务请求发送。
我已经NSString
使用此代码创建了结构化的 xml
NSMutableString *res = [NSMutableString string];
[res appendString:@"<question>"];
[res appendFormat:@"<productid>%@</productid>", [array objectAtIndex:0]];
[res appendFormat:@"<questionid>%@</questionid>", [array objectAtIndex:1]];
[res appendFormat:@"<valueid>%@</valueid>", [array objectAtIndex:2]];
[res appendFormat:@"<answerText>%@</answerText>", [array objectAtIndex:3]];
[res appendFormat:@"</question>"];
但是,当我将其作为请求发送(使用 sudzc 创建的 Web 服务代码)时,出现了一些错误
Entity: line 1: parser error : Start tag expected, '<' not found
Bad Request
Error: The operation couldn’t be completed. (CXMLErrorDomain error 1.)
这是我的发送字符串
NSString *send=[NSString stringWithString:@"<request><ProductName>ppr</ProductName><questionid>fff</questionid><answerText>%@</answerText></request>"];
创建字符串 xml 时我应该替换哪些所有标签?
这是我的要求,,
[service CreateRequest:self action:@selector(CreateRequestHandler:) Email:@"xxxx" Password:@"anoopgopalan" Token:@"xxx" Request:send];
- (void) CreateRequestHandler: (id) value {
// Handle errors
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
// Do something with the MFLAPIError* result
MFLAPIError* result = (MFLAPIError*)value;
NSLog(@"CreateRequest returned the value: %@", result);
}