我试图使用的API在检索它时返回乱码XML。
以下是将auth参数发布到端点的基本代码。AFNetworking XMLResponse正文是HTML编码,不可能解析
[[APIManager sharedManager] postPath:@"Authenticate"
parameters:params
success:^(AFHTTPRequestOperation *operation, XMLParser *xmlParser) {
//code
NSLog(@"Raw XML Data: %@", [[NSString alloc] initWithData:operation.responseData encoding:NSUTF8StringEncoding]);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//code
DLog(@"error: %@", error);
}];
我得到的回应是乱码,像这样:
Raw XML Data: <?xml version="1.0" encoding="utf-8"?><string xmlns="http://www.morningstarsoftware.com/"><MorningStar_BCE_WS><MyUserInfo><Tenant_Id>37</Tenant_Id><MsClient>OBC05</MsClient><Suite_Location>DA</Suite_Location><pseq>6690</pseq><CPResetAccess>false</CPResetAccess><CCPayor>N</CCPayor><CPAllowFinancial>false</CPAllowFinancial><CPAllowScheduler>true</CPAllowScheduler><CPAllowService>false</CPAllowService><FirstName>Gary</FirstName><LastName>Evans</LastName><OfferCC>Y</OfferCC><AllowACH>Y</AllowACH><MerchantAccount>121513</MerchantAccount><SQID>0</SQID><SQID2>0</SQID2><Ecom_payment_recurring /></MyUserInfo></MorningStar_BCE_WS></string>
我做得不对,或者是API只是返回这个错误?
什么是“乱码”? – matt 2013-05-02 02:36:50
嗯,编辑器解码了html编码的字符串,让我看看我是否可以编辑它来显示我实际得到的回应。 – 2013-05-02 18:25:47
那里,现在你可以看到如何“字符串”节点是一个HTML编码表示xml – 2013-05-02 18:26:57