Quella che segue è una funzione che converte una stringa HTML in una di testo semplice.
Imports System.Text
Imports System.Text.RegularExpressions
''' <summary>
''' Funzione che converte una stringa HTML in una di testo semplice
''' </summary>
''' <param name="html">Stringa da convertire</param>
''' <returns>Stinga semplice</returns>
''' <remarks></remarks>
Function Html2Text(ByVal html As String) As String
' pattern per la rimozione dei tag HTML
Dim pattern As String = "\<[^\>]*\>"
Dim re As New Regex(pattern, RegexOptions.IgnoreCase)
'qui posso modificare la formattazione sui
'tag che mi interessano, prima di eliminarli ad esempio
'html = html.Replace("<p>", vbCrLf)
'html = html.Replace("<\p>", vbCrLf & vbCrLf)
'html = html.Replace(" ", " ")
html = html.Replace("<br />", vbCrLf)
'applico l'espressione regolare,
'sostituendo i caratteri speciali con la stringa vuota
html = re.Replace(html, String.Empty)
Return html
End Function