将html标签解码为字符串

时间:2012-01-20 11:11:19

标签: asp.net

我的模型中有一个属性,其中包含如下所示的html字符串:

<p>Solution web de contr&ocirc;le financier &agrave; chacune des &eacute;tapes du cycle de soumission et de validation des d&eacute;penses. La gestion fortement param&eacute;trable des workflows favorise son int& eacute;gration avec des applications tierces (pgm de gestion des d&eacute;penses) et son d& eacute;ploiement dans une organisation d&eacute;centralis&eacute;e.< /p>

正如您所看到的,我们有一些html chacacters,如<p> &oirc; ...

我希望能够通过解码所有特殊字符来获取此字符串。我能怎么做?

这一行: <p>Solution web de contr&ocirc;le</p>

应该给我:解决方案网站

2 个答案:

答案 0 :(得分:1)

HttpUtility.HTMLDecode会做你需要的。

答案 1 :(得分:0)

使用HttpUtility.HtmlDecode

string decoded = HttpUtility.HtlmDecode("<p>Solution web de contr&ocirc;le</p>");

这将处理字符实体(&ocirc;),但您仍需要删除HTML标记。