flex xmlºÍarraycollectionÏ໥ת»»
1¡¢arraycollectionת»¯Îªxml£¬´úÂëÈçÏ£º
//¶¯Ì¬Éú³ÉÊ÷Ðνṹ
public static function flatArrayToXML(arr:Object,rootname:String=null,nodename:String=null, outputString:Boolean=false):Object{
if (arr is Array){
}else if ( arr is ArrayCollection){
arr= ArrayCollection(arr).source;
}else if (arr == null){
return null;
}
if (rootname==null) rootname="root";
var xmlstr:String="<"+rootname+" "+"label='ÌײÍÏîÄ¿'>";
var xmlList:XMLList=new XMLList();
var alength:int=arr.length;
if (alength > 0)
{
for (var i:int=0; i < alength; i++)
{
xmlstr+=objToSimpXML(arr[i].name,0,nodename,true);
}
xmlstr +="</"+nodename+">";
}
}
}
xmlstr+="</"+rootname+">";
trace(xmlstr);
var xmldoc:XMLDocument=new XMLDocument(xmlstr);
if (outputString==true)
return xmldoc==null ? "": xmldoc.toString();
var xml:XML=new XML(xmldoc);
return xml;
}
//½«¶ÔÏóת»»Îª¼òµ¥xml.<node property1='value1' property2='value2'/>ÕâÖÖÐÎʽ
//objת»»Ô´¶ÔÏó,½öÖ§³Ö¼òµ¥¶ÔÏó,Èç¹û¶ÔÏóµÄÊôÐÔÒ²ÊÇÒ»¸ö¶ÔÏóÔò²»½øÈëµÝ¹é,
//nodename¿ÉÒÔ×Ô¶¨Òå½ÚµãÃû³Æ, ĬÈÏÊÇ"node"
//ÊÇ·ñÊä³öΪ×Ö·û´®, ĬÈÏת»»Îªxml, Èç¹ûΪtrueÔò½«xml±äΪ×Ö·û´®
//return ÖµÀàÐ͸ù¾ÝoutputString À´¾ö¶¨, ¿ÉÄÜÊÇXML,¿ÉÄÜÊÇString
public static function objToSimpXML(ri_name:String,nodeorchild:int, nodename:String=null, outputString:Boolean=false):String{
if(ri_name==null) return null;
if (nodename==null)nodename="node";//½ÚµãÃû×Ö
var str:String="<"+nodename;
str+=" label='"+filterXMLString(ri_name)+"'";½ÚµãÖÐÊôÐÔµÄÃû×Ö
nodeorchild == 1?str+="/>":str+=">";
//
Ïà¹ØÎĵµ£º
¶ÔÓÚÏ°¹ßÁËʹÓÃ×ÀÃæÓ¦ÓóÌÐòµÄÓû§¶øÑÔ£¬»Ø³µºóÏÂÒƽ¹µãµ½ÏÂÒ»¸ö±à¼×é¼þÖеÄС¹¦ÄÜ£¬ÊǷdz£ÌùÐĵģ¬ÀûÓÃflexÖеÄKEY_DOWNʼþ¿ÉÒÔ·½±ãµÄʵÏֻسµÏÂÒƽ¹µã£¬´úÂëÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplet ......
[Bindable]¾ÍÊÇËùνµÄÔªÊý¾Ý±êÇ©¡£ÔªÊý¾Ý±êÇ©ÊÇÒ»ÖÖÌØÊâµÄ±êÇ©£¬ËüÔÚ´úÂëÖеÄ×÷ÓþÍÊÇÏò±àÒëÆ÷ÌṩÈçºÎ±àÒë³ÌÐòµÄÐÅÏ¢¡£Êµ¼ÊÉÏ£¬ÕâЩ±êÇ©²¢Ã»Óб»±àÒëµ½Éú³ÉµÄSWFÎļþÖУ¬¶øÖ»ÊǸæËß±àÒëÆ÷ÈçºÎÉú³ÉSWFÎļþ¡£
[Bindable]
BindableÔªÊý¾Ý±êÇ©ÊÇ×î¾³£Óõ½µÄÒ»¸öÔªÊý¾Ý±êÇ©£¬ÒòΪËüʹ³ÌÐò×é¼þÖ®¼äµÄÊý¾Ýͬ²½±äµÃºÜÈÝÒס£Bin ......
XML£¨Extensible Markup Language£©¼´¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ£¬ËüÓëHTMLÒ»Ñù£¬¶¼ÊÇSGML(Standard Generalized Markup Language,±ê׼ͨÓñê¼ÇÓïÑÔ)¡£XmlÊÇInternet»·¾³Öпçƽ̨µÄ£¬ÒÀÀµÓÚÄÚÈݵļ¼Êõ£¬Êǵ±Ç°´¦Àí½á¹¹»¯ÎĵµÐÅÏ¢µÄÓÐÁ¦¹¤¾ß¡£À©Õ¹±ê¼ÇÓïÑÔXMLÊÇÒ»ÖÖ¼òµ¥µÄÊý¾Ý´æ´¢ÓïÑÔ£¬Ê¹ÓÃһϵÁмòµ¥µÄ±ê¼ÇÃèÊöÊý¾Ý£¬¶øÕâЩ±ê¼Ç¿ÉÒÔÓà ......
XMLÊDZ»Éè¼ÆΪ´æ´¢¡¢´«ÊäÒÔ¼°½»»»Êý¾ÝµÄ¡£XML²»ÊDZ»Éè¼ÆΪÓÃÀ´ÏÔʾÊý¾ÝµÄ¡£
¡¡¡¡XML¿ÉÒÔ½«HTMLÓëÊý¾Ý·ÖÀë
¡¡¡¡Í¨¹ýʹÓÃXML£¬ÄúµÄÊý¾Ý¿É´æ´¢ÓÚHTMLÖ®Íâ¡£
¡¡¡¡µ±ÎÒÃÇʹÓÃHTMLÀ´ÏÔʾÊý¾Ýʱ£¬Êý¾Ý´æ´¢ÓÚHTMLÖС£Í¨¹ýʹÓÃXML£¬Êý¾Ý¿ÉÒÔ±»´æ´¢ÔÚµ¥¶ÀµÄXMLÎļþÖС£ÕâÑù×öµÄ»°£¬Äú¾Í¿ÉÒÔ°Ñ×¢ÒâÁ¦¼¯ÖÐÔÚʹÓÃHTML½øÐÐÊý¾Ý²¼¾Öº ......
ÔÚ XML ¶ÔÏóÄ£ÐÍÖÐÈçºÎ´¦Àí¿Õ°××Ö·û£¿
¡¡¡¡ÓÐЩʱºò£¬XML ¶ÔÏóÄ£Ðͽ«ÏÔʾ°üº¬¿Õ°××Ö·ûµÄ TEXT ½Úµã¡£¿Õ°××Ö·û±»½Ø¶Ïºó£¬¶à°ë»á´øÀ´Ò»Ð©»ìÂÒ¡£ÀýÈçÏÂÃæµÄ XML Àý×Ó£º
¡¡¡¡]>
¡¡¡¡Smith
¡¡¡¡John
¡¡¡¡Éú³ÉÏÂÁÐÊ÷£º
¡¡¡¡Processing Instruction: xml
¡¡¡¡DocType: person
¡¡¡¡ELEMENT: person ......