AppendHTML() Validation

Technical support for Spire.Doc

Moderator: iceblue support

AppendHTML() Validation

Postby » Fri Feb 15, 2013 9:40 am

i have a problem with the method appendHTML(), specifically with the w3 validation. It can happen that sometimes there is not valid html (For example: <p>Text....<p></ p></ p>),and then the page is in error:

Code: Select all
The element 'p' in namespace '' has invalid child element 'p' in namespace ''. List of possible elements expected: ' http://www.w3....

My question is whether it is possible to bypass this control or manage it in some way ?
In addition, there is a method to check if the text is OK or not to w3 validation? So we can periodically clean the database without the user crashed the system

Thank you
Posts: 20
Joined: Thu Sep 27, 2012 9:01 am

Re: AppendHTML() Validation

Postby » Sun Feb 17, 2013 9:19 am


Thanks for your inquiry.
It looks like your html code is not well-form. You can try this code
Code: Select all
doc.XHTMLValidateOption = Spire.Doc.Documents.XHTMLValidationType.None;

before calling AppendHTML() method. But I'm afraid that this error will occur still. Because the tag </ p> cann't be parsed. It means that you need to correct your html code. You can try
Code: Select all
html = Regex.Replace(html, @"\</\s*(\w+)\s*\>", "</$1>");

or other regex to fix it.

Technical Support / Developer,
e-iceblue Support Team
User avatar
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Re: AppendHTML() Validation

Postby amy.zhao » Wed Feb 20, 2013 7:37 am


Had your problem been solved? Please tell us if you still have the problem.

Best Regards,
E-iceblue support team
User avatar
Posts: 2279
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 0 guests