Adobe Flex Filter XMLList

时间:2012-11-08 22:06:25

标签: xml flex adobe

以下是我的XML文件的摘录:

 <car>
  <carname>AC</carname>
  <carmodellist>
    <carmodel>Cobra</carmodel>
  </carmodellist>
</car>

如何查询xmllistcollection并返回carmodellist中carname =='AC'的所有汽车?

我已经尝试了几种没有运气的组合,我认为它会与此类似:

var models:XMLListCollection = new XMLListCollection(vehicles.child(@car=='AC').carmodellist.children());

1 个答案:

答案 0 :(得分:3)

如果你有xml如下:

<cars>
    <car>
        <carname>AC</carname>
        <carmodellist>
            <carmodel>Cobra</carmodel>
            <carmodel>Cobra2</carmodel>
        </carmodellist>
    </car>
    <car>
        <carname>AB</carname>
        <carmodellist>
            <carmodel>Bobra</carmodel>
        </carmodellist>
    </car>
    <car>
        <carname>AD</carname>
        <carmodellist>
            <carmodel>Dobra</carmodel>
        </carmodellist>
    </car>
</cars>

然后:

vehicles.car.(carname == 'AC').carmodellist.children()