开发者

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 &lt;
> 开发者_C百科to &gt;
" to &quot;
' to &apos;
& to &amp;

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜