Flex 3处理外部XML的两种方法

点击这里使用RSS订阅本Blog: title="RSS 2.0" type="application/rss+xml" href="http://feed.feedsky.com/softwave" rel="alternate"> <script language="javascript"> </script> <script language="javascript" src="http://www.feedsky.com/jsout/publishlist_v2.js?burl=softwave&out_html=true"></script>

其一,用mx:Model:

  1. <?xml version="1.0"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  3.     <mx:Model id="catalogService" source="catalog.xml" />
  4.     <mx:ArrayCollection id="myXC" source="{catalogService.product}"/>
  5.     <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
  6.         <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
  7.     </mx:Repeater>
  8. </mx:Application>

其二:用mx:HTTPService:

  1. <?xml version="1.0"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="catalogService.send()">
  3.     <mx:HTTPService id="catalogService" url="catalog.xml" resultFormat="e4x"/>
  4.     <mx:XMLListCollection id="myXC" source="{catalogService.lastResult.product}"/>
  5.     <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
  6.         <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
  7.     </mx:Repeater>
  8. </mx:Application>

其中,XML数据如下:

  1. <?xml version="1.0"?>
  2. <products>
  3.   <product>
  4.     <name>Name</name>
  5.     <price>Price</price>
  6.     <freeship>Free Shipping?</freeship>
  7.   </product>
  8.   <product>
  9.     <name>Whirlygig</name>
  10.     <price>5</price>
  11.     <freeship>false</freeship>
  12.   </product>
  13.   <product>
  14.     <name>Tilty Thingy</name>
  15.     <price>15</price>
  16.     <freeship>true</freeship>
  17.   </product>
  18. <product>
  19.     <name>Really Big Blocks</name>
  20.     <price>25</price>
  21.     <freeship>true</freeship>
  22.   </product>
  23. </products>

请注意数据集的细微差别。


摘自【http://www.5uflash.com/Flex-AIR/flexziliao/list_17_2.html】



<script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script> <script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00697638153916680411/state/com.google/broadcast?n=5&callback=GRC_p%28%7Bc%3A%22green%22%2Ct%3A%22%5Cu8FD9%5Cu4E9B%5Cu6587%5Cu7AE0%5Cu4E5F%5Cu503C%5Cu5F97%5Cu4E00%5Cu770B%22%2Cs%3A%22false%22%7D%29%3Bnew%20GRC"></script>



<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值