方法一:
用URLLoader加载XML,然后将data转化为ByteArray
用byteArray.readMultiByte(bytes.length,"utf-8")
然后将转化后的字符串再强制转化为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);
}
方法三:在flex中的mxml文件中的mx:Application 下 加入initialize="flash.system.System.useCodePage=true"就能够解决flex读取外来xml乱码问题