如何使用C#解码这个html字符串?

时间:2012-09-27 04:23:20

标签: c# html

我有一些带有javascript格式字符串的字符串:

\u003Cdiv>\u003Cdiv class=\"mbm detail_research\">\u003Cdiv class=\"clearfix\">\u003Ca class=\"_8o _8r lfloat\" href=\"http:\/\/www.abcm.com\/mutily\/post.php?id=2344324342\" 

任何人都知道如何使用C#将其解码为普通的html字符串?

我的意思是它会成为:

<div><div class="mbm detail_research"><div class="clearfix"><a class="_8o _8r lfloat" href="http://www.abcm.com/mutily/post.php?id=2344324342"

解码后。

感谢您的帮助!

2 个答案:

答案 0 :(得分:4)

使用HttpUtility Class将其解码为:

String myDecodedString = HttpUtility.HtmlDecode("Html encoded String here");

关注此MSDN文章

答案 1 :(得分:2)

您要找的是Regex.Unescape

var decodedString = Regex.Unescape(yourString);