Flex read External XML garbled solution

Source: Internet
Author: User
Method One:

Load XML with Urlloader, then convert data to ByteArray
With Bytearray.readmultibyte (bytes.length, "Utf-8")
The converted string is then coerced into XML

var loader:urlloader = new URLLoader ();
Loader.dataformat = urlloaderdataformat.binary;
var urlrequest:urlrequest = new URLRequest (source);
Loader.addeventlistener ("complete", Completehandler);
Loader.load (URLRequest);

private var Completehandler (evt:event): void
{
var Bytes:bytearray = ByteArray (Evt.currentTarget.data);
var xmlstr:string = Bytes.readmultibyte (bytes.length, "utf-8");
var xml:xml = XML (XMLSTR);
Trace (XML);
} Method Two: Test down, in fact, the simplest thing is to convert your local XML file format to UTF-8, of course, your flex code is also UTF-8. Casually mention, when converting UTF-8 with Notepad Save As, I started with editplus tools do not. Method Three: Add Initialize= "Flash.system.system.usecodepage=true" to the mx:application in the Mxml file in flex to solve the problem of flex reading foreign XML garbled

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.