|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-23 13:16 UTC] dandrikop at cosmote dot gr
[2006-08-23 13:22 UTC] tony2001@php.net
[2006-08-23 13:33 UTC] dandrikop at cosmote dot gr
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 15:00:01 2025 UTC |
Description: ------------ I use the new DOM extension of PHP5. I want to pass special characters manually in the XML CDATA tags, but special characters such as '&' are automatically escaped. Reproduce code: --------------- <?php $imp = new DOMImplementation(); $dtd = $imp->createDocumentType( 'clickAPI', null, 'xml_dtd.txt' ); $xml_request = $imp->createDocument( null, null, $dtd ); $xml_request->version = '1.0'; $xml_request->formatOutput = true; // 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 " ) ); $text = $sendMsg->appendChild( new DOMElement( 'text' ) ); $text->appendChild( new DOMText( "Test " ) ); $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: ---------------- OK <?xml version="1.0"?> <!DOCTYPE clickAPI SYSTEM "xml_dtd.txt"> <clickAPI> <sendMsg> <session_id>aaaaaaaaaaaaaaaaa</session_id> <text>Test </text> <to>306978888888</to> </sendMsg> </clickAPI> Actual result: -------------- OK <?xml version="1.0"?> <!DOCTYPE clickAPI SYSTEM "xml_dtd.txt"> <clickAPI> <sendMsg> <session_id>aaaaaaaaaaaaaaaaa</session_id> <text>Test &#10;</text> <to>306978888888</to> </sendMsg> </clickAPI>