maddogandnoriko Posted April 14, 2009 Share Posted April 14, 2009 I have an xml file loaded into a simplexml object. The xml has a "ö" in it and is getting garbled in the simplexml object. Here is my test code: <?php $seriesURL='http://www.thetvdb.com/api/GetSeries.php?seriesname=krod'; echo 'SeriesURL:'.$seriesURL.'<br><br>'; $data = simplexml_load_file($seriesURL); echo '<br><br>'. ($data->Series->SeriesName); ?> The resulting Series Name is: Kröd Mändoon and the Flaming Sword of Fire Quote Link to comment Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 14, 2009 Share Posted April 14, 2009 http://www.thetvdb.com/api/GetSeries.php?seriesname=krod seem a valid utf-8 xml file. Try that at the begining of your php : <?php header('Content-Type: text/html; charset=utf-8'); ... ?> And in your output html : <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> ... </body> </html> It tell the browser (or whatever client) that your output is encoded in utf-8. Because the content in the xml is encoded in utf-8 (like it should). Or you can convert your data into ASCII html entities and it will work no matter what encoding you use with htmlentities() like that : <?php ... $output = htmlentities($data->Series->SeriesName, ENT_QUOTES, "UTF-8"); echo $output; ... ?> Don't encode the whole XML, only the data part. http://www.php.net/manual/en/function.htmlentities.php Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted April 14, 2009 Author Share Posted April 14, 2009 Thank you very much. maddogandnoriko Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.