如何在目标c中使用XMLparsing来发布带有特殊字符和泰语的string

我是新来的ios和我面临的问题,包括特殊字符后的string。 我的代码是这样在DidFinishLoading:

NSXMLParser *myNSXMLParserPostObj=[[NSXMLParser alloc]initWithData:myNSMDataPostFromServer]; myNSXMLParserPostObj.delegate=self; [myNSXMLParserPostObj parse]; NSLog(@"%@",myNSXMLParserPostObj.parserError); NSString *responseStringWithEncoded = [[NSString alloc] initWithData: myNSMDataPostFromServer encoding:NSUTF8StringEncoding]; //NSLog(@"Response from Server : %@", responseStringWithEncoded); NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[responseStringWithEncoded dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; serverResponse.attributedText = attrStr; NSString *Str =serverResponse.text; NSLog(@"Server Response =%@",Str); UIAlertView *alert3 = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Complaint Added Successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

为了从Web服务获取数据,我使用这样的代码

 loginStatusZone = [[NSString alloc] initWithBytes: [myNSMDatazoneFromServer mutableBytes] length:[myNSMDatazoneFromServer length] encoding:NSUTF8StringEncoding]; NSLog(@"loginStatus =%@",loginStatusZone); NSError *parseError = nil; NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:loginStatusZone error:&parseError]; NSLog(@"JSON DICTIONARY = %@",xmlDictionary); recordResultZone = [xmlDictionary[@"success"] integerValue]; NSLog(@"Success: %ld",(long)recordResultZone); NSDictionary* Address=[xmlDictionary objectForKey:@"soap:Envelope"]; NSLog(@"Address Dict = %@",Address); NSDictionary *new =[Address objectForKey:@"soap:Body"]; NSLog(@"NEW DICT =%@",new); NSDictionary *LoginResponse=[new objectForKey:@"FillZonesNewResponse"]; NSLog(@"Login Response DICT =%@",LoginResponse); NSDictionary *LoginResult=[LoginResponse objectForKey:@"FillZonesNewResult"]; NSLog(@"Login Result =%@",LoginResult); if(LoginResult.count>0) { NSLog(@"Login Result = %@",LoginResult); NSLog(@"Login Result Dict =%@",LoginResult); NSString *teststr =[[NSString alloc] init]; teststr =[LoginResult objectForKey:@"text"]; NSLog(@"Test String Value =%@",teststr); NSString *string = [LoginResult valueForKey:@"text"]; NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; zoneresponsedict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; idzonearray=[[NSMutableArray alloc]init]; idzonearray=[zoneresponsedict valueForKey:@"ZoneId"]; NSLog(@"Result Array =%@",idzonearray); shortnamezonearray=[[NSMutableArray alloc]init]; shortnamezonearray=[zoneresponsedict valueForKey:@"ZoneName"]; NSLog(@"Result Array =%@",shortnamezonearray); } 

如果我添加特殊字符,那么它会显示错误

 Domain=NSXMLParserErrorDomain Code=111 "The operation couldn't be completed. (NSXMLParserErrorDomain error 111.)" 

我如何发布特殊字符的数据?

我正在用泰语添加这样的东西

在这里输入图像说明

但是我越来越

在这里输入图像说明

和印地语一样

在这里输入图像说明

输出是这样的

在这里输入图像说明

但是,当任何人使用Android或网站添加泰语,我在泰国得到适当的文字。 唯一的问题是这个邮政编码。

有没有人做过这个,请帮忙。 提前致谢!

您需要像下面这样编写&<>,就像在html文件中一样:

 &amp; &lt; &gt;