I looked around a lot, but could not find a built-in .Net method that would avoid the special XML characters: < , > , & , ' and " if it is not a tag.
For example, take the following text:
Test& <b>bold</b> <i>italic</i> <<Tag index="0" />
I want it to be converted to:
Test& <b>bold</b> <i>italic</i> <<Tag index="0" />
Please note that tags are not escaped. I need to set this value in InnerXML XmlElement , and as a result, these tags must be saved.
I studied the implementation of my own analyzer and used StringBuilder to optimize as much as possible, but it can become quite annoying.
I also know acceptable tags that can simplify things (only: br, b, i, u, blink, flash, Tag). In addition, these tags may be closing tags.
(eg <u />)
or container tags
(eg <u>...</u>)
source share