Flex 3处理外部XML的两种方式 伯乐谷 中华英才网
Flex 3处理外部XML的两种方式
其一,用mx:Model:
- <?xml version="1.0"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
- <mx:Model id="catalogService" source="catalog.xml" />
- <mx:ArrayCollection id="myXC" source="{catalogService.product}"/>
- <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
- <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
- </mx:Repeater>
- </mx:Application>
其二:用mx:HTTPService:
- <?xml version="1.0"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="catalogService.send()">
- <mx:HTTPService id="catalogService" url="catalog.xml" resultFormat="e4x"/>
- <mx:XMLListCollection id="myXC" source="{catalogService.lastResult.product}"/>
- <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
- <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
- </mx:Repeater>
- </mx:Application>
其中,XML数据如下:
- <?xml version="1.0"?>
- <products>
- <product>
- <name>Name</name>
- <price>Price</price>
- <freeship>Free Shipping?</freeship>
- </product>
- <product>
- <name>Whirlygig</name>
- <price>5</price>
- <freeship>false</freeship>
- </product>
- <product>
- <name>Tilty Thingy</name>
- <price>15</price>
- <freeship>true</freeship>
- </product>
- <product>
- <name>Really Big Blocks</name>
- <price>25</price>
- <freeship>true</freeship>
- </product>
- </products>
请注意数据集的细微差别。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。