我使用下面的方法來剝去字符串中的所有HTML:HTMLagilitypack不會刪除所有的html標籤我如何有效地解決這個問題?
public static string StripHtmlTags(string html)
{
if (String.IsNullOrEmpty(html)) return "";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
return doc.DocumentNode.InnerText;
}
但似乎忽略了這個以下標籤:[…]
因此字符串basicly返回:
> A hungry thief who stole a rack of pork ribs from a grocery store has
> been sentenced to spend 50 years in prison. Willie Smith Ward felt the
> full force of the law after being convicted of the crime in Waco,
> Texas, on Wednesday. The 43-year-old may feel slightly aggrieved over
> the severity of the […]
哪有我確定這些標籤會被剝離?
任何形式的幫助表示感謝,謝謝。
''…不是HTML標籤。標籤有尖括號。這是一個編碼實體。 – jessehouwing