Function to validate Html Fragment

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

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 8 and 2 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910