Php, DomDocument iso8859-1, Umlaute, saveXML

From Andreida
Revision as of 11:57, 16 February 2016 by Andreas (talk | contribs) (Created page with "von: [http://www.cybton.com/view_thread,DomDocument+und+Umlaute,26427,1.html http://www.cybton.com/view_thread,DomDocument+und+Umlaute,26427,1.html] Folgender Code gibt eine ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

von: http://www.cybton.com/view_thread,DomDocument+und+Umlaute,26427,1.html

Folgender Code gibt eine Warning/Error aus, da saveXML mit dem Umlaut nicht klar kommt:

<?php
 
$doc = new DomDocument('1.0', 'iso-8859-1');
 
$documentElement = $doc->CreateElement('root');
$doc->appendChild($documentElement);
 
$textNode = $doc->CreateTextNode('Ein Text mit einem Umlaut: ä');
$documentElement->appendChild($textNode);
 
print $doc->saveXML();
 
?>

Lösung: utf8_encode; kein Witz :(