After scrubbing my field with AntiXss.HtmlEncode is there a way to remove all the html elements because they still show up as literals in the display?
+3
A:
No, there isn't. If you want to remove HTML elements and then HtmlEncode the result, you have to actually parse the code and remove the elements.
You can use the HTML Agility Pack or any other HTML parser to parse the content, get the InnerText of the root element (this will be only the text of the content) and then call AntiXss.HtmlEncode on that result.
casperOne
2010-06-24 18:35:21