2012-09-21 28 views
0

我的應用程序在以前的iOS版本上正常工作。我剛剛升級到iOS6,現在應用程序在處理XML請求/響應時返回錯誤。ASIHTTPClasses和iOS6

應用程序向服務器發送XML請求並接收XML響應,但現在響應爲空「<>」導致NSXMLParser失敗。

這裏是應用程序是如何發送請求(在此使用的工作,事先iOS6的):

[request setURL:[NSURL URLWithString:url]]; 
[request setHTTPMethod:@"POST"];  
[request setValue:postLength forHTTPHeaderField:@"Content-Length"]; 
[request setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"]; 
//[request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 
[request setHTTPBody:postData]; 




NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self]; 
if (conn) 
{ 

    receivedData = [[NSMutableData data] retain]; 

} 

但現在的響應是空「<>」。

parser error is Error Domain=NSXMLParserErrorDomain Code=9 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 9.)", path to file is : 

/Users/ronluna/Library/Application Support/iPhone Simulator/6.0/Applications/5BA74D89-1967-4B9E-A1C0-B076F7BB9064/Documents/Menus.xml 

任何想法可能是什麼問題?

回答

0

Hi iive也遇到了同樣的問題。嘗試更改您的xml文件的格式爲UTF-8沒有BOM或者如果您在服務器端腳本中填充您的xml,請嘗試將字符集更改爲UTF-8。希望這可以幫助。

0

請確保您使用xml格式指定的編碼創建您的NSData對象。 即,如果xml有utf-8編碼,你應該有: NSData * d = [xmlResponseStrings dataUsingEncoding:NSUTF8StringEncoding]; 在您的代碼中, 其他NSUnicodexxxxx編碼將不起作用。 希望得到這個幫助。