NSXMLParser problem with “&”(Ampersand) character

后端 未结 3 1845
误落风尘
误落风尘 2021-01-16 09:14

My NSXMLParsing is not working because of \"&\" character.. my code s below .any help please ?

 NSString *myRequestString = [NSString stringWithFormat:@         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-16 10:01

    Here's what worked for me:

    NSString *response = [[NSString alloc]initWithData:dataResponse encoding:NSUTF8StringEncoding];
    NSString *newResponse = [response stringByReplacingOccurrencesOfString:@"&:" withString:@"AND"];
    NSData *dataObj = [newResponse dataUsingEncoding:NSUTF8StringEncoding];
    

    If I replaced it with symbol '&', the response would be correct, but it would throw parsing error: 68. So I had to use 'and'.

提交回复
热议问题