您的位置:首页 > 其它

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>

这样就可以显示数据了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: