Special characters and accents
How do I parse xml's with accents?
NSStrings are Unicode aware, so it should just work. If it doesn't, it may be that the encoding of the XML isn't UTF8, in which case decide it as a string with the correct encoding first, then pass it to XMLDictionary.
http://sistemas.ideastek.com.br/cnordeste/classificacao.xml?grupo=A Is there something wrong with this XML? I read something about appending strings on -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
We just ran into a similar issue when parsing an XML server response with user generated data. When it hit a name that contained what I would guess was an accent mark, or other unicode character (Â is what rendered in our website browser page in chrome for that name). What happened is it appeared to have silently failed, exiting out of parsing all the remaining child elements of an element. The first 2 elements parsed, and when it hit the third, containing the element with the Unicode character, it stopped, skipping the remaining elements. The rest of the XML was parsed correctly. We have a library on android that handled it fine, but it failed miserably using this library.
It would be nice if it encounters that scenario, that we get some sort or NSError response. I've looked through the project code, but found no clear way errors are being handled if it encounters invalid characters, or NSXMLParser encounters an error. There are delegate methods for error handling, but they appear to not be implemented. I'd be happy to add it if you need. It may be that there is a problem with NSXMLParser, just not sure at this point, but it does give credence to the lfarah's request of handling real world Unicode problems. We were able to go in and remove the offending character to make our systems working, but that does not bode well for real world issues.
Issues with ' apostrophe. Content = "you're";
The quote " works Content = "you"re";
- (NSString *)XMLEncodedString
{
return [[[[[self stringByReplacingOccurrencesOfString:@"&" withString:@"&"] stringByReplacingOccurrencesOfString:@"<" withString:@"<"] stringByReplacingOccurrencesOfString:@">" withString:@">"] stringByReplacingOccurrencesOfString:@""" withString:@"""] stringByReplacingOccurrencesOfString:@"'" withString:@"'"];
}
Not sure why this isnt working.