|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-17 14:41 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 16:00:01 2025 UTC |
Description: ------------ An XML-String appended to a DOMDocumentFragment with appendXML() must always be encoded with UTF-8, regardless of the choosen DOMDocument encoding. Even worse, after appending the fragment to the document, the charset in the fragment remains UTF-8, which leads to a DOMDocument with mixed encodings inside. Reproduce code: --------------- $dom = new DOMDocument('1.0','ISO-8859-1'); $dom->loadXML('<parent />'); $frag = $dom->createDocumentFragment(); $frag->appendXML('<child>???</child>'); $dom->documentElement->appendChild($frag); Expected result: ---------------- the ISO-8859-1 encoded XML-String will cleanly import into the document fragment. Actual result: -------------- Error: DOMDocumentFragment::appendXML() Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding !! When trying to use an XML-declaration containing the ISO-8859-1 encoding in the child-XML-String: Entity: line 1: parser error : XML declaration allowed only at the start of the document When you convert the child-XML-String to utf8 and append it, you have a DOMDocument with mixed charset