After I changed your XML and code to be this one, it works for me.
XML file:
<?xml version="1.0"?>
<!DOCTYPE test [
<!ENTITY abcd "xyz">
]>
<test>&abcd;</test>
C++ code:
int main()
{
XMLPlatformUtils::Initialize();
{
DOMLSParser*
parser=DOMImplementation::getImplementation()->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS,
0);
parser->getDomConfig()->setParameter(L"entities", true);
DOMDocument const* const document =
parser->parseURI("undefined_entity.xml");
std::cout << entity_reference_node_found(document) << '\n';
parser->release();
}
XMLPlatformUtils::Terminate();
}
The "entities" property has to be set on the parser, not on the final
DOMDocument; and, if you want to set the "entities" property, you have
to use the DOMLSParser class as dictated by the W3C specs. If you want
to use the non-standard XercesDOMParser, you should use
XercesDOMParser parser;
parser.setCreateEntityReferenceNodes(true);
parser.parse("undefined_entity.xml");
DOMDocument const* const document = parser.getDocument();
std::cout << entity_reference_node_found(document) << '\n';
Alberto
Igor Ignatyuk wrote:
With this file too:
<?xml version="1.0"?>
<!DOCTYPE test
<!ENTITY abcd "xyz">
<test>&abcd;</test>
The entity is defined but the program prints 0.
Igor