XML DOMDocument (as well as JSON) expect to receive UTF8 data.
So, we convert data we receive to UTF-8.
For XML, the final output will be converted to the declared encoding (eg. iso8859-1) by saveXML.