rokerkony Posted July 7, 2010 Share Posted July 7, 2010 Hi, I need to import data from XML file. I have my web page in UTF-8 encoding and XML file is also in UTF-8. when I load XML file (with czech content) with function simplexml_load_file($file) so i get for example "TĂlka" or "zimnĂ snowboardovĂ© bundy" etc. I try to use iconv, but i don't know how, when the both encoding must be the same :-/ thanks for answer xml file is here: http://www.konradcerny.cz/xml.xml Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/ Share on other sites More sharing options...
bh Posted July 7, 2010 Share Posted July 7, 2010 Is your xml coded in UTF-8? (not the file, the xml content... <?xml version="1.0" encoding="UTF-8"?>) Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082401 Share on other sites More sharing options...
rokerkony Posted July 7, 2010 Author Share Posted July 7, 2010 Is your xml coded in UTF-8? (not the file, the xml content... <?xml version="1.0" encoding="UTF-8"?>) It should be... you can look at it in file http://www.konradcerny.cz/xml.xml Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082406 Share on other sites More sharing options...
bh Posted July 7, 2010 Share Posted July 7, 2010 Its utf-8 content. Is your php file in utf-8? And the site and your xml file is utf-8 you sure? Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082418 Share on other sites More sharing options...
rokerkony Posted July 7, 2010 Author Share Posted July 7, 2010 yes, my php file is in UTF-8 too ... it's so weird... :-/ Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082426 Share on other sites More sharing options...
bh Posted July 7, 2010 Share Posted July 7, 2010 Perhaps your utf-8 coding is utf8 with bom! If it is (you can see it with a clever editor or netbeans...) try to convert it to utf8 without bom. Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082428 Share on other sites More sharing options...
rokerkony Posted July 7, 2010 Author Share Posted July 7, 2010 i look at it and there is no BOM :-/ :-( for sure i try to create new UTF8 file and the same problem... Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082445 Share on other sites More sharing options...
rokerkony Posted July 7, 2010 Author Share Posted July 7, 2010 I tried to write this simple code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> </head> <body> <?php $xml = simplexml_load_file('http://www.konradcerny.cz/xml.xml'); foreach($xml as $value) { $_COLOR = $value->COLOR; echo $_COLOR; exit; } ?> </body></html> and it's working.... But the thing is that I import data from XML in the model ... i mean that it has no idea about HTML and meta tag "content-type" ... Quote Link to comment https://forums.phpfreaks.com/topic/206999-load-xml-problem-with-encoding/#findComment-1082535 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.