打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Flex 3处理外部XML的两种方式 伯乐谷 中华英才网

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

其一,用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>

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Portable RIAs Tutorial | James Ward - RIA Cowboy
Flex 入门教程
【转载】flv视频网站制作 使用Flex和PHP创建自己的视频应用
Flex Builder教程
BlazeDS入门教程
Flex与Java通信 BlazeDS方式 最详尽的解析
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服