Adobe AIRÃÔÄã½Ì³Ì ±¾µØÎļþ(XMLÎļþ)µÄ²Ù×÷£¨1£©
ÂòÁËÕ½Õù»úÆ÷2£¬Ð´Íê½Ì³Ì×¼±¸É±µ½Ë¯¾õ£¬ÏÖÔÚÏÈ×öµÚÒ»²½£¬Ð´½Ì³Ì¡£AIRµÄÎļþ²Ù×÷²»ÄÑ£¬¿´Íê½Ì³ÌÓ¦¸Ã¿ÉÒÔÂú×ãÄã¶ÔÎļþµÄËùÓлù±¾²Ù×÷¡£ÕâÆª½Ì³ÌÖ÷ÒªÒÔʵ¼Ê²Ù×÷ÖÐÓöµ½µÄÇé¿öÀ´½²½â
ÎÒÃÇÏëÏëÎļþ²Ù×÷¶¼»áÓÐʲôÄÚÈÝ£¬ÎÞ·ÇÊÇ´´½¨£¬Ð޸ģ¬É¾³ý£¬Òƶ¯£¬¿½±´¡£ÔÚÕâ¸ö¹ý³ÌÖÐÎÒÃÇ»áÉæ¼°µ½Ò»Ð©ÖܱߵIJÙ×÷£¬±ÈÈçÎļþ¼Ð£¬ÎļþÑ¡ÔñÆ÷£¬ÎļþÁÐ±í£¬ÎļþÐÅÏ¢»ñÈ¡µÈ¡£ ÎÒ¾ÍÎ§ÈÆ´´½¨£¬Ð޸ģ¬É¾³ý£¬Òƶ¯£¬¿½±´À´Õ¹¿ªÎÒÃǵĽ̡̳£ÒòΪÄÚÈݱȽ϶࣬»ùÓÚÃÔÄã½Ì³Ìÿƪ¶¼¶ÌС£¬Ò×¶ÁµÄÔÔò¡£ÎÒ·ÖΪÁ½Æª£¬½ñÌìÏȽ²µÚһƪ£¬»ù±¾µÄ²Ù×÷£¬ÏÂһƪÎÒÔÙ¼ÓÈëÉÏÃæËù˵ÖܱߵIJÙ×÷Ïà¶ÔÉîÒ»²½µÄ½²½â¡£
AirµÄÎļþ²Ù×öÖ÷񻃾¼°Á½¸öÀ࣬FIleºÍFileStream¡£Ò»°ãÀ´ËµÎÒÃDz»»áÖ±½ÓÒÔÎı¾ÐÎʽ±£´æÎļþ£¬ÄÇÑùµÄÄÚÈݲ»Ò×ÓÚÐ޸ģ¬ËùÒÔÕâÀïÎÒÒÔxml ÎļþΪÀý¡£
Note: ÏÂÃæËùÓеÄfunction¿ÉÒÔÖ±½Ó¸´ÖƵ½ÄãµÄ´úÂëÖÐÔËÐÐ
1.´´½¨ÐÂÎļþ¡£
public function createFileDemo():void{
var file:File = File.desktopDirectory.resolvePath("test.xml") //³¢ÊÔ´Óϵͳ×ÀÃæ»ñÈ¡test.xmlÎļþ¡£
var fileStream:FileStream = new FileStream(); // ´´½¨FileStream ¶ÔÏó£¬ÓÃÓÚ¶ÁдÎļþ
fileStream.open(file,FileMode.WRITE); //ÒÔWRITE·½Ê½´ò¿ªfile, Èç¹ûfileÖжÔÓ¦µÄÎļþ²»´æÔÚ£¬´´½¨ÐÂÎļþ
//×¼±¸ÎļþµÄÄÚÈÝ
var content:XML =
ÎÒÃǵĵÚÒ»¸öÎļþ´´½¨Íê±Ï
fileStream.writeUTFBytes(content.toXMLString()); //ÏñÎļþÖÐдÈëÄÚÈÝ¡£
fileStream.close(); //Íê³ÉдÈ룬ÕâʱÎÒÃÇ´ò¿ª×ÀÃæµÄtest.txt¿ÉÒÔ¿´µ½ÄÚÈÝ¡£
}
ÉÏÃæÎå¾ä´úÂëÈÃÎÒÔÚÎÒµÄ×ÀÃæ´´½¨ÁËÃûΪtest.xmlµÄÎļþ£¬²¢ÇÒдÈëÁËcontent¡£
ÕâÀïÓÐÈý¸öµØ·½ÎÒÃÇҪעÒâ
1. File.desktopDirectory -- ÒòΪAIR¿ÉÒÔÔÚMacºÍWindowsÏÂÔËÐУ¬ËùÒÔÎÒÃÇ×îºÃ²»ÒªÖ¸¶¨¹Ì¶¨µÄµØÖ·£¬ÕâÀïFile.desktopDirectoryµÄÒâ˼¾ÍÊÇÖ¸ÏòÎÒϵͳµÄ×ÀÃæ£¬ÒòΪÎÒÊÇmac£¬ËùÒÔʵ¼Ê·µ»ØµÄÊÇ /kevinluo/Desktop. ³ý´ËÖ®ÍâÎÒÃÇ»¹¿ÉÒԵõ½ÈçÏÂÃæÕâЩµØÖ·
File.documentsDirectory; //Ö¸ÏòÓû§ÎĵµÎļþ¼Ð
File.applicationDirectory; //Ó¦ÓóÌÐò°²×°Ä¿Â¼
File.getRootDirectories(); //Îļþϵͳ¸ùĿ¼
µÈµÈ£¬ÎҾͲ»Ò»Ò»ÁоÙÁË£¬¾ßÌåµÄ´ó¼Ò¿ÉÒÔ¿´File°ïÖúÖÐÃèÊö¡£
2.File.desktopDirectory.resolvePath("test.xml") -- »ñÈ¡×ÀÃæÏµÄtest.xml¡£ÕâÀïÎÒÃÇ»¹¿ÉÒÔÕâÑùд
var file:File = File.desktopDirectory
file = file.resolvePath("test.xml")
²»¹ýÎÒ½¨Ò黹ÊÇÖ±½ÓдÔÚÒ»ÅÅ£¬Èç¹ûÏ
Ïà¹ØÎĵµ£º
http://topic.csdn.net/u/20080905/10/caea1689-4582-417a-8723-d008a3ae1a10.html?550638422
tringBuilder sb = new StringBuilder();
sb.Append(" <?xml version=\"1.0\"?> ");
......
2£®DOMʵÀý
ÓÐÁËÉÏÃæµÄ½éÉÜ£¬ÏàÐÅÄã¶ÔDOMÀí½âµÄ¸ü¶àÁ˰ɡ£ÏÂÃæµÄÀý×Ó½«ÈÃÄã¶ÔDOM¸ü¼ÓÊìϤÆðÀ´¡£
ÏÈ˵˵Õâ¸öÀý×Óµ½µ×Òª×öµÄÊÇʲô°É£¬ÎÒÃÇÏ£ÍûÔÚÒ»¸öÃûΪlink.xmlÎļþÖб£´æÁËһЩURLµØÖ·£¬Í¨¹ýÒ»¸ö¼òµ¥µÄ³ÌÐò£¬ÎÒÃÇ¿ÉÒÔͨ¹ýDOM°ÑÕâЩURL¶Á³ö²¢ÏÔʾ³öÀ´£¬Ò²¿ÉÒÔ·´¹ýÀ´ÏòÕâ¸öXMLÎļþÖÐдÈë¼ÓÈëµÄURLµØÖ·¡£ºÜ¼òµ¥£¬È´ºÜÊµÓ ......
Ìí¼Ó¼Ç¼µ½ds±£´æµ½xml
DataSet ds = new DataSet("myDs");
//´ÓXMLÖжÁÈ¡Êý¾Ý
ds.ReadXml(Serve ......
1£©
XMLÊÇÒ»ÏîÈÈÃŵļ¼Êõ¡£ËüÖ®ËùÒÔÄܹ»ÒýÆðÈËÃǵÄÐËȤ£¬Ò»¸öÖ÷ÒªµÄÔÒòÔÚÓÚËüÊ®·ÖµÄ¼òµ¥£¬ÈËÃÇ¿ÉÒÔºÜÈÝÒ×µØÀí½âºÍʹÓÃËü¡£Ã¿Ò»¸ö³ÌÐòÔ±¶¼ÄÜÇáÒ׵ؿ´¶®Ò»¸öXMLÎļþ£¬Àí½âËü°üº¬µÄÄÚÈÝ¡£
.NETÖаüº¬Á˺ܶàÖ§³ÖXMLµÄÀ࣬ÕâЩÀàʹµÃ³ÌÐòԱʹÓÃXML±à³Ì¾ÍÈçͬÀí½âXMLÎļþÒ»Ñù¼òµ¥¡£ÔÚÕâÆªÎÄÕÂÖУ¬ÎÒ½«¸ø³öÕâÑùµÄÒ»¸öÀàµÄʹÓÃʾ ......
<?xml version="1.0" encoding="utf-8"?>
<LinkLibrary xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Link Cat="aa" Url="aa" Desc="aa" />
<Link Cat="bb" Url="aa" Desc="aa" />
<Link Cat="cc" Url="aa" Desc="aa" />
&l ......