List和XmlListCollection的数据绑定
2012-10-28 15:46
344 查看
请看一下一个例子。
//xml文件,名为catalog.xml
<catalog>
<category>
<name>Dairy</name>
<categoryID>4</categoryID>
</category>
<category>
<name>Deli</name>
<categoryID>5</categoryID>
</category>
<category>
<name>Fruit</name>
<categoryID>3</categoryID>
</category>
<category>
<name>Meat</name>
<categoryID>1</categoryID>
</category>
<category>
<name>Seafood</name>
<categoryID>6</categoryID>
</category>
<category>
<name>Vegetables</name>
<categoryID>2</categoryID>
</category>
</catalog>
//创建内容为以上的Xml文件
var xml = new xml (catalog.xml);
//创建一个XmllistCollection
var xlc:XmlListCollection ;
//由于XmlListCollection用的数据是需要以根节点一下一个节点为起点来创建,也就是创建的节点是需要有多项的,比如category。有多项
xlc = new XmlListCollection(xml.category);
//如上
//那么这是List了
<s:list dataProvider = {xlc} labelField = "name";
<s:list>
这样就可以显示数据了。
//xml文件,名为catalog.xml
<catalog>
<category>
<name>Dairy</name>
<categoryID>4</categoryID>
</category>
<category>
<name>Deli</name>
<categoryID>5</categoryID>
</category>
<category>
<name>Fruit</name>
<categoryID>3</categoryID>
</category>
<category>
<name>Meat</name>
<categoryID>1</categoryID>
</category>
<category>
<name>Seafood</name>
<categoryID>6</categoryID>
</category>
<category>
<name>Vegetables</name>
<categoryID>2</categoryID>
</category>
</catalog>
//创建内容为以上的Xml文件
var xml = new xml (catalog.xml);
//创建一个XmllistCollection
var xlc:XmlListCollection ;
//由于XmlListCollection用的数据是需要以根节点一下一个节点为起点来创建,也就是创建的节点是需要有多项的,比如category。有多项
xlc = new XmlListCollection(xml.category);
//如上
//那么这是List了
<s:list dataProvider = {xlc} labelField = "name";
<s:list>
这样就可以显示数据了。
相关文章推荐
- Castor的XML数据绑定应用
- CheckBoxList动态绑定数据按需换行
- XML数据绑定
- XML,XMLList,XMLListCollection之间的关系笔记
- TreeView绑定xml数据源
- FLEX XML XMLList XMLListCollection ArrayCollection相互转换
- jsp中将后台传递过来的json格式的list数据绑定到下拉菜单select
- DevExpress TreeList 调优_绑定数据源方式, 放弃原来的AppendNode加载数据的方式
- Flex--之XML、XMLLIST和XMLListCollection的关系和区别
- java 将数据字典(父子结构)绑定成List集合(第二种写法)
- 利用ListControl控件来绑定分层次的数据
- 读取Xml文件,创建DataTable,递归循环Xml节点,添加数据到DataTable,绑定到GridView
- Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件
- 一个用ArrayCollection作为数据格式 读取远程XML绑定到DropDownList例子
- SpringMVC数据绑定四(list、set和map)
- WPF and Silverlight 学习笔记(二十五):使用CollectionView实现对绑定数据的排序、筛选、分组
- springMVC对简单对象,Set,List,Map的数据绑定及类型转换
- FLEX实践—XML、XMLList、 XMLListCollection、ArrayCollection关系转换
- 微信小程序WXML 数据绑定、列表渲染、条件渲染、模板、事件、引用用法
- flex学习进度9之访问xml的XMLListCollection