Search code examples
phpxmlencodingutf-8iso-8859-1

Change encoding of an xml file in php


I have opened a server which is waiting for queries. When i send a query, the server will answer it and safe the results in an xml file. Problem is, that I can't use this xml properly because in the first line of the xml is now written:

xml version="1.0 encoding="utf-8"

if I change this in the editor into:

xml version="1.0 encoding="iso-8859-1

than it works fine. But instead of using editor and my hands, i want php to do it? Thx


Solution

  • Just to close the question: I used str_replace(str,'utf-8','iso-8859-1') in the xml file, which helped me to open the xml file in the right way. Thx to you