dom document save() encoding problem
Posted: Fri Jul 15, 2011 2:43 pm
I have been having trouble retaining the encoding type of an xml file. the file is opened fine, changes are made fine, then the file is saved fine. However, somewhere in this process the character encoding changes. Special characters written as say: & #174; end up looking like this: ®
why would the encoding change on save if it is correctly declared when the dom document is made?
Code: Select all
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load('/rawInventory.xml');
$xpath = new DOMXPath($dom);
$sohs = $xpath->query('/ac//soh');
//changes are made then the file is saved:
$dom->save('/rawInventory.xml');