note 94371 deleted from domdocument.loadxml by danbrown

From: Date: Sat, 31 Oct 2009 15:48:12 +0000
Subject: note 94371 deleted from domdocument.loadxml by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162310@lists.php.net to get a copy of this message
Note Submitter: cuisdy at gmail dot com ---- to 'szalma dot laszlo at zengo dot eu' If you want to make sure you always got the encoding, whether it was declared or not, take the documentElement instead of the DOMDocument, and preface it with the encoding. $tmp_doc->loadXML( '<?xml version="1.0" encoding="utf-8"?>'.$someXMLDoc->saveXML($someXMLDoc->documentElement) ); I was having the same problem here. Although I found a much better solution for my particular problem, this workaround might still be useful for someone: $tmp_doc = new DOMDocument; $tmp_doc->loadXML( '<?xml version="1.0" encoding="utf-8"?>'.$xSomeNode->ownerDocument->saveXML($xSomeNode) ); echo $tmp_doc->saveXML();

« previous php.notes (#162310) next »