For my application I have to save an XML document containing a few elements with HTML-text. Example as the result should be:
<gpx>
<wpt>
<elementInHTML>
<p>Sample text.</p>
</elementInHTML>
etc...
But when I add this html element to my NSXMLDocument the '<' (to <
) is correctly escaped automatically, but the '>' not (to >
).
In code:
NSXMLElement *newWPT = [NSXMLElement elementWithName:@"wpt"];
NSXMLElement *htmlElement = [NSXMLElement elementWithName:@"elementInHTML"];
htmlElement.stringValue = @"<Sample text>";
[newWPT addChild:htmlElement];
But this results in an XML document like this:
<gpx>
<wpt>
<elementInHTML>
<p>Sample text.</p>
</elementInHTML>
etc...
And this result is not valid for the device that has to process this xml file.
Anybody an idea how to enclose a correctly escaped html-string into a NSXMLDocument?
Sample text
";` in your example, I get `