We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Validation / Fixing of XHTML

Hi,

we are generating some word documents using DocIO and Mail Merge. The XHTML is coming from your RTE Element and stored in a database. Unforunately we have some older Entries there from the RTE when there was no EnableXHTML() Feature. This ist throwing some exceptions with invalid <br> or <img ...>, ...

We have tried many approaches to get this HTML fixed in MVC with many Packages, but there seems to be no up-to-date solution for this except developing some custom solution on our own. Is there some tool in your products to validate or even fix html strings before inserting them into the document?

king regards,
lc

1 Reply

SK Sathish K Syncfusion Team September 30, 2015 02:48 PM UTC

Hi Lc,

Thank you for contacting Syncfusion support.

Currently Essential DocIO supports, only XHTML 1.0 complaints for the HTML. We internally perform the XHTML 1.0 validation for the input HTML in DocIO and then process the document further. If the input HTML fails to meet the XHTML 1.0 complaints then exception will be thrown with respect the unsupported elements. You can check your input HTML in the following link to ensure whether it meets the XHTML 1.0 complaints or not.

Link:
http://validator.w3.org/check

You shall also use the below code to check whether the given HTML string is valid or not using DocIO.

Code example:
WordDocument doc = new WordDocument();           
doc.EnsureMinimal();
bool isValidHtmlString = doc.LastSection.Body.IsValidXHTML(htmlString, XHTMLValidationType.Strict);

Note:
Please do not use “None” validation type for validating the HTML string in the above code. Kindly use “Strict” or “Transitional” validation types.

Regards,
Sathish


Loader.
Live Chat Icon For mobile
Up arrow icon