[英]Strip all HTML code from String with C#
我目前正在將一些數據從SQL Server數據庫中提取到C#asp.net頁面中。
我使用以下(部分)代碼來輸出存儲在我的body
列中的HTML文本:
TextLabel.Text += "<div class=\"newsEntry\">" +
Convert.ToString(reader2["body"]).Substring(0, 220) +
"...<a href='entry.aspx?ID=" + reader2["ID"] +
"' title=\"Read More about " + reader2["Title"] +
"\">Read More »</a></div>";
我想刪除其中所有HTML的正文值( + Convert.ToString(reader2["body"]).Substring(0, 220) +
)。
我如何用C#實現這一目標?
通常使用PHP,我會使用striptags
。
非常感謝任何幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.