ASP.NET | Cancellare i tag html da un testo
Questa funzione permette di eliminare tutti i tag html da un testo: Function CleanHtml(ByVal html As String) As String html = html.Replace(“>”, “> “) Dim doc = New HtmlAgilityPack.HtmlDocument() doc.LoadHtml(html) Dim text As String = HttpUtility.HtmlDecode(doc.DocumentNode.InnerText) Return Regex.R
Questa funzione permette di eliminare tutti i tag html da un testo:
Function CleanHtml(ByVal html As String) As String html = html.Replace(“>”, "> ") Dim doc = New HtmlAgilityPack.HtmlDocument() doc.LoadHtml(html)
Dim text As String = HttpUtility.HtmlDecode(doc.DocumentNode.InnerText) Return Regex.Replace(text, “\s+”, " ").Trim() End Function
Per il corretto funzionamento, occorre inserire nella cartella Bin del progetto, la dll allegata al post