我是 ios 编程新手,我正在尝试解析 XML 字符串:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SurveyListGetResponse xmlns="http://tempuri.org/"><SurveyListGetResult>{"SurveyList":[{"SurveyID":1,"SurveyName":"SomeSurvey","SurveyDescription":"Clean","BeginDate":"01.01.2013","EndDate":"05.01.2013"}],"Questions":[{"SurveyID":1,"QuestionID":8,"Question":"Mobile Question","AnswerTypeID":2}],"Answers":[{"SurveyID":1,"QuestionID":8,"AnswerID":18,"Answer":"YES"},{"SurveyID":1,"QuestionID":8,"AnswerID":19,"Answer":"Hayör"}]}</SurveyListGetResult></SurveyListGetResponse></soap:Body></soap:Envelope>
这是我的 xml 字符串,正如您在上面看到的,“答案”:“Hayör”中有土耳其语字符,我检查了所有字符串,解析器将一直运行到“Hay”,但它不使用“ör”。
NSData *xmlData = [responseString dataUsingEncoding:NSWindowsCP1254StringEncoding];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
[xmlParser setDelegate:self];
[xmlParser parse];
这是我的解析器代码,我习惯使用 NSWindowsCP1254StringEncoding 和 NSUTF8StringEncoding。aftes 字符串将被解析,它正在改变{"SurveyList":[{"SurveyID":1,"SurveyName":"Some Survey","SurveyDescription":"Clean","BeginDate":"01.01.2013","EndDate":"05.01.2013"}],"Questions":[{"SurveyID":1,"QuestionID":8,"Question":"Mobil Soru","AnswerTypeID":2}],"Answers":[{"SurveyID":1,"QuestionID":8,"AnswerID":18,"Answer":"YES"},{"SurveyID":1,"QuestionID":8,"AnswerID":19,"Answer":"Hay
我需要做什么来解决它?对不起我的英语不好,谢谢。