I'm running this code:
NSXMLElement *element = [NSXMLElement elementWithName:@"name" stringValue:@"value\n"];
NSXMLDocument *document = [[NSXMLDocument alloc] initWithRootElement:element];
NSLog(@"%@", document.XMLString);
And I'm getting this result:
<name>value
</name>
But I'm expecting the result to be:
<name>value
</name>
Does anybody know why NSXMLDocument doesn't escape \n? Is it an expected behavior?
I also tried XMLStringWithOptions: with different options, e.g. NSXMLNodePreserveWhitespace, but with no luck.