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)

       {

           HtmlAgilityPack.HtmlDocument doc = new 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)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345