Here is my sample XML for an XML document that consists of metadata about print templates:
<TemplateList>
<PaperSizeTemplates PaperSize="8.5x14">
<Template>Letter ANSI A Landscape</Template>
<Template>Letter ANSI A Portrait</Template>
</PaperSizeTemplates>
<PaperSizeTemplates PaperSize="A3_11.5x16">
<Template>A3 Landscape</Template>
<Template>A3 Portrait</Template>
</PaperSizeTemplates>
<PaperSizeTemplates PaperSize="A4_8.5x11">
<Template>A4 Portrait Custom</Template>
<Template>A4 Portrait Custom1</Template>
<Template>A4 Portrait Custom2</Template>
</PaperSizeTemplates>
</TemplateList>
I have a spark DropDownList whose dataProvider I want to set such that the PaperSize attribute values for all PaperSizeTemplates elements display in the DropDownList.
For example, for the XML shown above, I want my DropDownList to display the following:
8.5x14
A3_11.5x16
A4_8.5x11
I tried the following:
<s:DropDownList id="paperSizeDDL" dataProvider="{_layoutTemplatesXML.paperSizeTemplates.paperSize as XMLListCollection}" />
but nothing appears in the drop down list.
Help on this would be greatly appreciated.
Please provide the correct way to do this using data binding and my example XML.
Thanks!
The other answers are somewhat on the mark, but won’t work. Note that @Mike Petty’s comment about matching the case in your e4x statements to the case used in the XML is one part of the problem.
However, the other issue is that e4x statements return
XMLListobjects. They don’t return anXMLListCollection. So this expression evaluates to null:Instead, set the data provider for the drop down list like this:
This populates the drop down list with 3 XML objects who’s values are Strings for each size.