helpdesk
helpdesk

Reputation: 2074

Adding three or more XMLLISTCollections in Flex

I have an XML structure :

<xml>
  <a>
   <name>A</name>
   <schl>AB</schl>
   </a>
  <a>
   <name>B</name>
<schl>BC</schl>
  </a>
  <b>
   <name>C</name>
   <schl>CD</schl>
   </b>
    <c>
     <name>D</name>
      <schl>DE</schl>
   </c>
</xml>

now, I need an XMLListCollection variable that should contain only the name elements of element a, b and c.. so, I tried something like this :

var combXml:XMLListCollection  = new XMLListCollection();
combXml.addItem(new XMLListCollection(xml.a.name);
combXml.addItem(new XMLListCollection(xml.b.name);
combXml.addItem(new XMLListCollection(xml.c.name);

and then pass it to a dataprovider..

treeDP.dataProvider = combXml;

but I got an error.

Does anyone knows how to combine these elements into the combXml?

Upvotes: 0

Views: 394

Answers (1)

Imran
Imran

Reputation: 3024

You can use Directly one XML source for 3 ComboBoxes as

<mx:ComboBox id="a" dataProvider="{myXml.a}" labelField="name"/>
<mx:ComboBox id="b" dataProvider="{myXml.b}" labelField="name"/>
<mx:ComboBox id="c" dataProvider="{myXml.c}" labelField="name"/>

myXml is a xml varaiabe and myXml.a returns XmlList object

equals to

var axList:XMLList = myXml.a;

EDITED: To get all elements[a,b,c] name you should use it as

<mx:ComboBox id="d" dataProvider="{XML(myXml).elements('*').name}" labelField="name"/>

Hopes that helps

Upvotes: 2

Related Questions