|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-07-12 17:14 UTC] john dot enevoldson at pulsen dot se
Description:
------------
Encoding attribute is lost when using loadXML following a create new DOMDocument.
Reproduce code:
---------------
$doc3 = new DOMDocument('1.0','iso-8859-1');
$doc3->loadXML('<root></root>');
print $doc3->saveXML();
Expected result:
----------------
<?xml version="1.0" encoding="iso-8859-1"?>
<root/>
Actual result:
--------------
<?xml version="1.0"?>
<root/>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
The encoding of the loaded XML (which is utf-8 in your case) overwrites the one specified in "new DOMDocument" and that's expected behaviour. use instead: $doc3 = new DOMDocument('1.0'); $doc3->loadXML('<root></root>'); $doc3->encoding = 'iso-8859-1'; print $doc3->saveXML(); and it works as you want