An equally quick alternative to SecurityElement.Escape(string) to escape XML special characters?
I ran across this SecurityElement.Escape(string)
method to escape special XML characters in a String, however it seems to be oddly placed in the Security namespace considering I'm just using the generic System.Xml namespace and a basic String of XML, not really security related.
It converts the following special XML characters.
< to <
> 开发者_C百科to >
" to "
' to '
& to &
Is there an equally quick static method call somewhere inside the XML namespace for escaping these characters, without using higher level classes like XmlReader, XmlDocument, etc?
A good summary of the options is in the following:
Different ways to escape XML
精彩评论