c++tinyxml2

TinyXML-2 error loading file with stylesheet


I have a function to load a xml file with TinyXML-2 library (v4.0.1). It always work fine, but today I see a problem that I don't know how to solve.

When I load de file:

if ( doc.LoadFile ( "file.xml" ) != tinyxml2::XML_SUCCESS )

It never return XML_SUCCESS. I'm watching many files and I see that only fail when the file has this line:

<?xml-stylesheet ...

Without this line it works fine. Why it's happening? What can I do for solve this problem?

Thanks.


Solution

  • TinyXML2 does not support XML style sheets or document type definitions (DTDs) From the documentation:

    TinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs (eXtensible Stylesheet Language.)

    That is why the XML read of the file with the <?xml-stylesheet ... definition is failing. Try commenting out this section. TinyXML2 observes the XML comment syntax of <!-- your comment -->