简体   繁体   中英

Php xml encoding issue

Hi guys after 5 hours of research and trying everything I'm so desperate so I write here. I have an XML file coming from a third party. When I try to parse it with SimpleXMLElement it simply says that the string is not in valid XML format and I also found out that this happens due to ANSI encoding the XML file is having. I tried converting the file to UTF-8 -> it gets read by the parser but all my Cyrillic symbols are lost, replaced by meaningless chars. Then in notepad++ I copied the content created a file with utf8 encoding and pasted the content -> it was just fine and got read by the parser. I tried to do it with code but no result -> I get contents of the file, create a file with first bytes, the bytes of UTF-8 file, output the content and when I open it -> meaningless chars instead of Cyrillic. Help me please I really need to convert this file to UTF-8 valid for the XML parser or could you please tell me another way to parse the file from XML to array.

您需要弄清楚原始XML文件的编码方式,然后可以使用iconv将其转换为UTF8。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM