Reputation: 303
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.
Upvotes: 4
Views: 110
Reputation: 22777
Because \n
is valid xml. If you really want values to be URL encoded, you'll need to encode them.
Upvotes: 2