0
我有meta標籤,它包含html標籤。我想刪除這個。 實施例的內容爲:如何在視圖MVC中刪除元標記的html標記?
<p><b>This is red color</b><br>
這是鑑於剪斷代碼MVC
<meta name="description" content="@Model.description" />
參數@Model.description
包含內容的文本。
我有meta標籤,它包含html標籤。我想刪除這個。 實施例的內容爲:如何在視圖MVC中刪除元標記的html標記?
<p><b>This is red color</b><br>
這是鑑於剪斷代碼MVC
<meta name="description" content="@Model.description" />
參數@Model.description
包含內容的文本。
您可以使用正則表達式替換您的html標記。例如,
string myContent = Regex.Replace(description, @"<(.|\n)*?>", string.Empty);
或者,否則,您可以使用WebUtility.HtmlDecode爲.NET 4.0+和舊版本 HttpUtility.HtmlDecode。
希望它有幫助:)
您是否正在尋找剝離html標籤?看看這個[thread](https://stackoverflow.com/q/785715/728795) – Andrei