|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-24 10:47 UTC] tony2001@php.net
[2006-08-24 10:49 UTC] dandrikop at cosmote dot gr
[2006-08-25 11:56 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ The PHP DOM extension cannot resolve entities declared in an external DTD file. Reproduce code: --------------- <?php $imp = new DOMImplementation(); $dtd = $imp->createDocumentType( 'clickAPI', null, 'clickatell.dtd' ); $xml_request = $imp->createDocument( null, null, $dtd ); $xml_request->version = '1.0'; $xml_request->encoding = 'ISO-8859-1'; $xml_request->formatOutput = true; $xml_request->resolveExternals = true; $xml_request->substituteEntities = true; $xml_request->standalone = false; // Create the tag 'clickAPI'. $clickAPI = $xml_request->appendChild( new DOMElement( 'clickAPI' ) ); // Create the tag 'sendMsg'. $sendMsg = $clickAPI->appendChild( new DOMElement( 'sendMsg' ) ); // Add elements under the 'auth' tag. $sendMsg->appendChild( new DOMElement( 'session_id', 'aaaaaaaaaaaaaaaaa' ) ); $sendMsg->appendChild( new DOMElement( 'text', "Test &testme;" ) ); $sendMsg->appendChild( new DOMElement( 'to', '306978888888' ) ); if( $xml_request->validate() ){ echo "OK\n"; } else { echo "Not OK!\n"; } echo "\n" . $xml_request->saveXML() . "\n"; ?> Expected result: ---------------- <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <!DOCTYPE clickAPI SYSTEM "clickatell.dtd"> <clickAPI> <sendMsg> <session_id>aaaaaaaaaaaaaaaaa</session_id> <text>Test HELLO</text> <to>306978888888</to> </sendMsg> </clickAPI> Actual result: -------------- <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <!DOCTYPE clickAPI SYSTEM "clickatell.dtd"> <clickAPI> <sendMsg> <session_id>aaaaaaaaaaaaaaaaa</session_id> <text>Test &testme;</text> <to>306978888888</to> </sendMsg> </clickAPI>