J'utilise la méthode suivante pour supprimer tout le code HTML de la chaîne:
public static string StripHtmlTags(string html)
{
if (String.IsNullOrEmpty(html)) return "";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
return doc.DocumentNode.InnerText;
}
Mais il semble ignorer cette balise suivante: […]
Donc la chaîne retourne basly:
> A hungry thief who stole a rack of pork ribs from a grocery store has
> been sentenced to spend 50 years in prison. Willie Smith Ward felt the
> full force of the law after being convicted of the crime in Waco,
> Texas, on Wednesday. The 43-year-old may feel slightly aggrieved over
> the severity of the […]
Comment puis-je m'assurer que ce type de balises est dépouillé?
Toute aide est appréciée, merci.
Essayez HttpUtility.HtmlDecode
public static string StripHtmlTags(string html)
{
if (String.IsNullOrEmpty(html)) return "";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
return HttpUtility.HtmlDecode(doc.DocumentNode.InnerText);
}
HtmlDecode convertira […]
en […]