List和XmlListCollection的数据绑定

来源:互联网 发布:淘宝扣分什么时候清零 编辑:程序博客网 时间:2024/05/20 09:49

请看一下一个例子。


//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>


这样就可以显示数据了。






原创粉丝点击