删除字符串中的HTML实体 [英] Removing HTML entities in strings

查看:86
本文介绍了删除字符串中的HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在按下链接按钮时检索到的文本:

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

似乎正在检索HMTL实体。如何将它们转换回普通字符串?

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

推荐答案

您不需要删除HTML实体,实际上是删除您在这里显示的是 HTML编码,因此您只需执行 Html Decoding 即可将其转换为标准格式。

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.

为此,您具有 HttpUtility.HtmlDecode 方法。

string normalString = HttpUtility.HtmlDecode(myEncodedString);

如果您使用的是.NET 4.0或更高版本,则还可以使用WebUtility.HtmlDecode

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

这篇关于删除字符串中的HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆