Search code examples
iosxmlgdata

GDataXMLNode and Umlauts


from the following code snippet the value of xmlString is <ELEMENT NAME="&#xF6;&#xE4;&#xFC;"> instead of <ELEMNT NAME="öäü">.

GDataXMLElement *element = [GDataXMLNode elementWithName:@"ELEMENT"];

GDataXMLNode *a = [GDataXMLNode elementWithName:@"NAME" stringValue:@"öäü"];

[element addAttribute:a];

[parentElement addChild:element];

GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithRootElement:parentElement];

NSString *xmlString = [NSString stringWithFormat:@"%@", [[doc rootElement] XMLString]];

I know someone is trying to convert my characters into unicode but they should not be converted because the backend can't handle the additional &.

Anyone knows how to solve this problem?


Solution

  • Setting the character encoding with [doc setCharacterEncoding:@"UTF-8"]; did the trick.