flexÖÐxmlת»¯ÎªarrayʵÀý
±¾ÎĹ²Á½¸öÎļþ£ºtranslate.mxml ºÍ mapmarking.xml
1¡¢translate.mxml
<?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/halo"
minWidth="1024" minHeight="768">
<fx:Script>
<![CDATA[
//xml translate array
public function xmlToArr(xmlObj:XML):Array{
var toArr:Array = new Array();
for(var i:uint = 0; i < xmlObj.site.length(); i++){
toArr.push({pid: xmlObj.site[i].id,
province: xmlObj.site[i].province,
city: xmlObj.site[i].city,
updName: xmlObj.site[i].station,
latitude: xmlObj.site[i].ypos[0],
longitude: xmlObj.site[i].xpos,
telephone: "110"
});
}
return toArr;
}
//parse the array
private function arrParse():void{
var arr:Array = xmlToArr(xmlID);
for(var i:int = 0; i < arr.length; i++){
trace(arr[i].updName + "========" + arr[i].longitude);
}
}
]]>
</fx:Script>
<mx:Button id="butID" horizontalCenter="0" fontSize="18"
label="xml translate array" click="arrParse();"/>
<fx:Declaration
Ïà¹ØÎĵµ£º
Æäʵ¶ÔÓÚÕâ¸öÌâÄ¿ÊDz»Ç¡µ±µÄ£¬ÒòΪflexÖÐÊÇûÓÐÒ³ÃæÕâ¸ö¸ÅÄîµÄ£¬Ò³ÃæÔÚflexÀïÃæÆäʵ¾ÍÊÇÒ»¸ö¸öµÄCanvas£¬vbox£¬
hboxµÈµÈÖ®ÀàµÄ¶«Î÷£¬¿´µ½µÄ²»Í¬Ò³ÃæµÄÇл»£¬¾ÍÊÇÕâЩԪËØÒ»²ã²ãµÄ¶Ñ»ý£¬»òÕßÌæ»»£¬µ«ÊÇΪÁ˺ÃÀí½â£¬»¹ÊdzÆ֮Ϊ
"Ò³ÃæÌøת"¡£ÆäʵÎÒÃÇ¿ÉÒԶԱȴ«Í³µÄC/S¿ª·¢Ä£Ê½£¬Ã»Ò³ÃæÌøת£¬Ö»Óд°ÌåºÍÔª¼þµÄÏÔʾºÍÒþ²Ø¡ ......
protected void btn_write_Click(object sender, EventArgs e)
{
XmlWriterSettings settings=new XmlWriterSettings();
settings.Indent=true;
setting ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script><!--[CDATA[import mx.collections.ArrayCollection;
public var a1:ArrayCollection = new ArrayCollection ([{ Region:"Region1",Territory:"Territory1",Ter ......
1¡¢Ê¹ÓÃnavigateToURL£¬Ö÷Òª·½Ê½ÈçÏ£ºvar url:String = "http://localhost:8080/Flex_J2eeDemo/bin/Welcome.html";
&n ......