If you want save document with not typical encoding for example utf-8 (russian letters)

If you do like this:
$doc = new DOMDocument('1.0','UTF-8');
It will be wrong, because php does't know what encoding will be.For normal working you should use:
$doc->encoding='UTF-8';
ps: Next will be some articles about working with xml in php