加载外部XML文档
代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
private function onClick():void
{
var XMLURL:URLRequest = new URLRequest("booklist.xml");
var myLoader:URLLoader = new URLLoader(XMLURL);
myLoader.addEventListener("complete",Loaded);
}
public function Loaded(event:Event):void
{
var myLoader:URLLoader = URLLoader(event.target);
XML.ignoreProcessingInstructions=false;
var xml:XML = new XML(myLoader.data);
var outStr:String = "";
outStr = xml.toXMLString();
ta_view.text = outStr;
}
]]>
</fx:Script>
<s:TextArea id="ta_view" width="224" height="323">
</s:TextArea> www.zzzyk.com
<s:Button label="加载XML数据" id="loader" click="onClick()" x="65.5" y="331"/>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
</s:Application>
补充:Web开发 , 其他 ,