When I try to read an XML document (eagle file) with an DTD I get the error:
Project xx raised exception class EDOMParserError with message 'DTD is prohibited'
The XML header looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
If I remove the second line...
<!DOCTYPE eagle SYSTEM "eagle.dtd">
...everything works fine.
After some googling it seems like the MSXML parser have an option called ´prohibitDTD´ set to true by default (in earlier versions it was false).
However it seems not possible to set this option to false from the TXMLDocument class. One solution seems to be a recompile of the .pas library or to create the interface on my own with CoCreateInstance().
All examples I have seen out there are in Delphi and I'm having dificulties to trasnlate these to C++ Builder.
Does anyone know how to read a DTD XML document with C++ Builder XE2?
My example code...
#include <xmldoc.hpp>
_di_IXMLNode XMLObject;
TXMLDocument *XMLDocument = new TXMLDocument(this);
XMLDocument->LoadFromFile(fileName); // <----- Exception EDOMParserError
XMLObject = XMLDocument->DocumentElement;
Thank you...
XE2 introduced a native solution to this very problem: there is a global
bool
variable namedMSXML6_ProhibitDTD
declared inXml.Win.msxmldom.hpp
. You can set it tofalse
before loading data intoTXMLDocument
:On a side note: it is generally not a good idea to create
TXMLDocument
instances dynamically like this. It is better to use theIXMLDocument
interface instead: