Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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")
²»¹ýÎÒ½¨Ò黹ÊÇÖ±½ÓдÔÚÒ»ÅÅ£¬Èç¹ûÏ


Ïà¹ØÎĵµ£º

ʹÓÃkxml½âÎöxmlÎļþ(Ò»)

Õâ¸öÊDzÎÕÕibmÍøÕ¾ÉϵÄÎÄÕÂ×öµÄ¡£
xmlÔ´Îļþ£º
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd"
>
<rss version="0.91">
<channel>
<title>Meerkat: An Open2 Wire Servic ......

ThroughoutCMS¼¼Êõ¹²ÏíϵÁУ¨2£©£ºXML·ÃÎÊÀà

     ÉϴΰÑÊý¾Ý¿â·ÃÎÊÀ๲Ïí³öÀ´ÁË£¬¼¸¸öͬÊÂÍøÉϸп®ÁËÒ»·¬£¬ÕæµÄûÓÐÏëµ½ÎÒ»¹±£Áô5ÄêÇ°µÄ´úÂ룬ÎÒ˵£¬´úÂë±¾À´¾ÍÊÇÓ¦¸Ã±»ÔĶÁºÍÑо¿µÄ£¬´úÂëͬÑù¾ßÓÐ˼ÏëºÍÇé½Ú£¬Õâ¾ÍÊÇÔÚÒ»Çî¶þ°×µÄÇé¿öϵÄÀúÊ·ºÍ¹ì¼£¡£ÅäÖùÜÀíͬÑùÒ²ÊÇһλ¾¡Ö°µÄÊ·¹Ù¡£
     ×ܽáһϣ¬Éϴθø³öµÄ´úÂë ......

ʹÓÃkxml½âÎöxmlÎļþ(¶þ)

Ò». ²»Í¬XML¸ñʽÉϵIJîÒì
<Bil BilID="09120005">
<Product PID="XS000-3">
<Package Needuan="10"/>
<Package Needuan="8"/>
</Product>
</Bil>
 
Óë
<channel>
<title>Meerkat: An Open2 Wire Service</title>
<link>http://meerkat. ......

C#¶ÁдXMLÎļþ

1£©
XMLÊÇÒ»ÏîÈÈÃŵļ¼Êõ¡£ËüÖ®ËùÒÔÄܹ»ÒýÆðÈËÃǵÄÐËȤ£¬Ò»¸öÖ÷ÒªµÄÔ­ÒòÔÚÓÚËüÊ®·ÖµÄ¼òµ¥£¬ÈËÃÇ¿ÉÒÔºÜÈÝÒ×µØÀí½âºÍʹÓÃËü¡£Ã¿Ò»¸ö³ÌÐòÔ±¶¼ÄÜÇáÒ׵ؿ´¶®Ò»¸öXMLÎļþ£¬Àí½âËü°üº¬µÄÄÚÈÝ¡£
.NETÖаüº¬Á˺ܶàÖ§³ÖXMLµÄÀ࣬ÕâЩÀàʹµÃ³ÌÐòԱʹÓÃXML±à³Ì¾ÍÈçͬÀí½âXMLÎļþÒ»Ñù¼òµ¥¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«¸ø³öÕâÑùµÄÒ»¸öÀàµÄʹÓÃʾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ