Problem with encoding when dumping xml file (domDocument)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jharp
Forum Newbie
Posts: 1
Joined: Wed Jul 15, 2009 4:10 am

Problem with encoding when dumping xml file (domDocument)

Post by jharp »

Hi,

I got a problem with the encoding of special characters like umlaut when dumping them to an xml-file. The problem occurs on dump_file. The dump_mem output is correctly encoded but dump_file outputs 䶼 instead of the umlauts. How can I get the file output to b e correct too? Below is the code, the dump_mem output and the dimp_file output.

Thank you for the help :)

Code:

Code: Select all

header('Content-Type: text/xml');
 
$doc = domxml_new_doc("1.0");
$root = $doc->add_root("root");
 
$head = $root->new_child("head", "");
$head->new_child("title", "äöü");
 
echo $doc->dump_mem(true,"utf-8");
$doc->dump_file($_SERVER["DOCUMENT_ROOT"] ."/widget_feed/"."testumlaut.xml", false, true);
 
dump_mem output:

Code: Select all

 
<?xml version="1.0" encoding="utf-8"?>
<root>
  <head><title>äöü</title></head>
</root>
 
 

dump_file output:

Code: Select all

 
<?xml version="1.0"?>
<root>
  <head><title>&#x4DBC;</title></head>
</root>
 
Post Reply