Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Feb 15, 2013 9:40 am

Hi,
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 'http://www.w3.org/1999/xhtml' has invalid child element 'p' in namespace 'http://www.w3.org/1999/xhtml'. List of possible elements expected: 'http://www.w3.org/1999/xhtml:a http://www.w3.org/1999/xhtml:br http://www.w3.org/1999/xhtml:span http://www.w3.org/1999/xhtml:bdo http://www.w3.org/1999/xhtml:object http://www.w3.org/1999/xhtml:applet http://www.w3.org/1999/xhtml:img http://www.w3.org/1999/xhtml:map http://www.w3.org/1999/xhtml:iframe http://www.w3.org/1999/xhtml:tt http://www.w3.org/1999/xhtml:i http://www.w3.org/1999/xhtml:b http://www.w3.org/1999/xhtml:u http://www.w3.org/1999/xhtml:s http://www.w3.org/1999/xhtml:strike http://www.w3.org/1999/xhtml:big http://www.w3.org/1999/xhtml:small http://www.w3.org/1999/xhtml:font http://www.w3.org/1999/xhtml:basefont http://www.w3.org/1999/xhtml:em http://www.w3.org/1999/xhtml:strong http://www.w3.org/1999/xhtml:dfn http://www.w3.org/1999/xhtml:code http://www.w3.org/1999/xhtml:q http://www.w3.org/1999/xhtml:samp http://www.w3.org/1999/xhtml:kbd http://www.w3.org/1999/xhtml:var http://www.w3.org/1999/xhtml:cite http://www.w3.org/1999/xhtml:abbr http://www.w3.org/1999/xhtml:acronym 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

info@isis.it
 
Posts: 20
Joined: Thu Sep 27, 2012 9:01 am

Sun Feb 17, 2013 9:19 am

Hi,

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.

Regards,
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Wed Feb 20, 2013 7:37 am

Hello,

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

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc