I search for and process XML files from elsewhere, and need to transform them with some XSLTs. No problem. Using PHP5 and the DOM library, everything\'s a snap. Worked fine,
Does this work for you?
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->load($xmlPath);
Edit: Since it appears that this doesn't work, what you could do instead is similar to your existing method but without the temp file. Read the XML file from your source just using standard IO operations (file_get_contents()
or something), then perform whatever changes to the encoding you need (iconv()
or utf8_decode()
) and then use loadXML()
$myXMLString = file_get_contents($xmlPath);
$myXMLString = utf8_decode($myXMLString);
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->loadXML($myXMLString);