My code generate some dynamic HTML fragments and I want to know does the html valid.
Thanks to HtmlAgilityPack it is easy:
Debug.Assert(IsValidHtmlFragment(pricesTable));
public static bool IsValidHtmlFragment(string html)
{
Microsoft.SDC.HtmlAgilityPack.HtmlDocument doc = new Microsoft.SDC.HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
return (doc.ParseErrors.Count==0);
}
posted @ Thursday, July 26, 2007 5:52 PM