Removing HTML entities in strings

时光毁灭记忆、已成空白 提交于 2020-02-02 04:11:32

问题


I have text that is retrieved on a linkbutton press:

When I press the button I am getting the following returned:

Test UAT's for release 2.2.0

It looks like HMTL entities are being retrieved. How do I turn these back into normal strings?


回答1:


You don't need to remove the Html entities, actually the string that you are showing here is HTML Encoded so you just need to do Html Decoding to get it in normal form.

For that you have HttpUtility.HtmlDecode method.

string normalString = HttpUtility.HtmlDecode(myEncodedString);

If you are using .NET 4.0 or higher then you can also use WebUtility.HtmlDecode




回答2:


Use HttpUtility.HtmlDecode to decode the string.



来源:https://stackoverflow.com/questions/19692654/removing-html-entities-in-strings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!