I have an external xml file which I have to pick up, no encoding is set but I have discovered it it’s payload is encoded ISO-8859-1.
I know this because if I manually edit the file to encoding=”ISO-8859-1″ then it is processed as expected.
Can I tell simplexml what encoding to deal with as I instantiate the simplexml object?
Addendum
Because the xml file was so dirty I might end up using xmllint – posting here for anyone else interested – format so it is indented, set encoding where it did not exist and clean up bad entities (& and so on)
xmllint --format --encode iso-8859-1 -o cleansed.xml dirty.xml
You can set the encoding for a DomDocument and then convert it to simplexml by using simplexml_import_dom():