[100] xml_parse_into_struct function parses XML, Chinese garbled characters

Source: Internet
Author: User
[100 points for help] the xml_parse_into_struct function parses XML. The Chinese garbled test code is as follows: $ xmldata & nbsp ;=& nbsp; '& lt ;? Xml & nbsp; version = "1.0" & nbsp; encoding = "UTF-[100 points for help] xml_parse_into_struct function parse XML, Chinese garbled characters
The test code is as follows:

$ Xmldata =' Chinese ';
$ Parser = xml_parser_create ('utf-8 ');
$ Vals = array ();

Xml_parse_into_struct ($ parser, $ xmldata, $ vals );
Xml_parser_free ($ parser );

Print_r ($ vals );


PHP version 5.4.20

In the conversion result, the Chinese part is garbled.

Have you ever encountered this problem and how to solve it ...... Thank you!
------ Solution --------------------
Apparently, your program file is gbk's
$ Xmldata =' Chinese ';
$ Xmldata = iconv ('gbk', 'utf-8', $ xmldata );


------ Solution --------------------
In fact, you can also use iconv transcoding.
However, my display is normal. no garbled characters. it is estimated that the browser code is incorrect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.