An equally simple alternative to SecurityElement.Escape (string) to avoid special XML characters?

I came across this method SecurityElement.Escape(string)to avoid special XML characters in String, however it seems to fit weirdly into the Security namespace given that I just use a common System.Xml namespace and a non-security XML base string.

It converts the following special XML characters.

< to &lt;
> to &gt;
" to &quot;
' to &apos;
& to &amp;

Is there an equally fast call to a static method somewhere inside the XML namespace to escape these characters without using higher-level classes such as XmlReader, XmlDocument, etc.?

+3
source share
1 answer
+2

Source: https://habr.com/ru/post/1795255/


All Articles