views:

24

answers:

1

Hi!

I'm using a HorizontalList control with an XML file as a data provider. This is how the XML looks:

<data>
    <zone name="Europe">
        .
        .
        .
    </zone>
    <zone name="Japan">
        <stores>
            .
            .
            .
        </stores>
        <collections>
            <collection id="id1">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id1Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
        </collections>
        <clarities>
            .
            .
            .
        </clarities>
    </zone> 
</data>

And this is how my control looks

<mx:XML id="data" source="assets/SOD_division.xml"/>

<mx:HorizontalList 
    dataProvider="{data.division.(@name=='Japan').collections}"
    columnCount="2"
    itemRenderer="Renderer"
    width="500"
    horizontalScrollPolicy="off"
    />

I tried using an array of objects as a dataprovider. The item renderer works and the horizontallist behaves as I expect it to. However, when I use an xml file, it's empty....

I don't know why it's not working... -_-' ...

Thanks for any help you can provide =)

Regards, BS_C3

+1  A: 

First thing I notice is that your DP is set as:

dataProvider="{data.division.(@name=='Japan').collections}"

But that's not the structure of your XML. By following your XML example your DP should be:

dataProvider="{data.zone.(@name=='Japan').collections}"

Now thats going to return an XML object when you probably want an XMLList object in which case your DP should be

dataProvider="{data.zone.(@name=='Japan').collections.collection}"

or if you don't care about the local name of the children:

dataProvider="{data.zone.(@name=='Japan').collections.children()}"
invertedSpear
Thanks!!It managed to make it work thanks to your answer =)FYI, in my original XML I use "division" and not "zone" =P
BS_C3
Your Welcome and welcome to the world of e4x, once you get e4x down it's pretty amazing what you can do with it.
invertedSpear