Is there any option to have a less strict html validator?

edited September 2012
I am trying to do some queries on a table which has a column which contains a html style email message, but when I call Util.RawHtml on the column it gives the error Cannot parse custom HTML: '

The following samples give an illustration of a good and bad example which seems to be caused by the presence of <meta> and <br> tags without the corresponding </meta> and </br> tags.

var html = @" <html> <head> <meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1""></meta> </head> <body> <b>Hello</b><br></br>world. </body> </html> "; Util.RawHtml(html).Dump(); // Works fine var html2 = @" <html> <head> <meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1""> </head> <body> <b>Hello</b><br>world. </body> </html> "; Util.RawHtml(html2).Dump(); // Throws error Cannot parse custom HTML:

Is there anything that can be done to display such messages?


Apologies for the formatting, hopefully this will be readable.


  • Util.RawHtml emits an XElement which feeds into a larger XDocument when dumped (along with everything else that you Dump). This is why it must be valid XML - otherwise the XElement constructor will throw an exception.

    LINQPad's Dump method is implemented mostly as a LINQ query, which is why it relies on LINQ to XML.
  • Thanks.

    I decide to forget about trying to display to message but instead display a link which opens a webbrowser ie

    (from msg in messages
    select new { msg.DateTime, msg.Subject ,
    Link = (new Hyperlinq(
    String.Format("new System.Windows.Forms.WebBrowser()" +
    " {{ DocumentText = System.Uri.UnescapeDataString( \"{0}\") }} "
    , System.Uri.EscapeDataString(msg.BodyHtmlText)) ,
    "Click here to view message"))

    I also needed to add System.Windows.Forms.dll to the defaults
Sign In or Register to comment.