【100分】xml_parse_into_struct 函数解析XML,中文乱码

WBOY
Release: 2016-06-13 12:29:37
Original
692 people have browsed it

【100分求助】xml_parse_into_struct 函数解析XML,中文乱码
测试代码如下:

<br />
$xmldata = '<?xml version="1.0" encoding="UTF-8"?><description>中文</description>';<br />
$parser = xml_parser_create ('UTF-8');<br />
$vals = array();<br />
<br />
xml_parse_into_struct ($parser, $xmldata, $vals);<br />
xml_parser_free ($parser);<br />
<br />
print_r($vals);<br />
Copy after login


PHP版本为5.4.20

转换结果中,中文部分为乱码。

请教下大家,有没有哪位遇到过这个问题,如何解决……谢谢!显然你的程序文件时 gbk 的
$xmldata = '中文';
$xmldata = iconv('gbk', 'utf-8', $xmldata);

其实你iconv转码也是可以的 
但是我这边显示是正常的没有乱码 估计是浏览器的编码不对

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!