HTML agility pack - removing unwanted tags without removing content?

前端 未结 5 2214
忘了有多久
忘了有多久 2020-11-29 03:00

I\'ve seen a few related questions out here, but they don’t exactly talk about the same problem I am facing.

I want to use the HTML Agility Pack to remove unwa

5条回答
  •  無奈伤痛
    2020-11-29 03:23

    If you do not want to use Html agility pack and still want to remove Unwanted Html Tag than you can do as given below.

    public static string RemoveHtmlTags(string strHtml)
        {
            string strText = Regex.Replace(strHtml, "<(.|\n)*?>", String.Empty);
            strText = HttpUtility.HtmlDecode(strText);
            strText = Regex.Replace(strText, @"\s+", " ");
            return strText;
        }
    

提交回复
热议问题