1

I am trying to create a xmllist variable in action script like this:

var _menuData:XMLList;              
                <menuitem label="File">
                    <menuitem label="Backup Schedule"/>
                    <menuitem label="Restore Schedule"/>                    
                </menuitem>
                <menuitem label="Edit">
                    <menuitem label="Cut"/>
                    <menuitem label="Copy"/>
                </menuitem>

How do I assign this xml to _menuDAta in actionScript? I dont want to create a string first and then do it all by fixing line break errors. Thanks.

splash
  • 13,037
  • 1
  • 44
  • 67
Tintin
  • 2,853
  • 6
  • 42
  • 74

2 Answers2

3

I can't see your code here but here is a sample code for creating an XMLList:

var xml:XML = <items><item>1</item><item>2</item><item>3</item></items>;
var xmlList:XMLList = xml.item;
trace(xmlList);

Hope it helps, Rob

robertp
  • 3,557
  • 1
  • 20
  • 13
  • I have uncovered the source code in the question, so that you can update your answer. – splash Mar 17 '11 at 15:53
  • Thanks Rob,but is there not a direct way of creating XMLList variable? I mean whithout having to add xml variable to list every time? thanks. – Tintin Mar 17 '11 at 16:36
  • It seems like you can't populate an XMLList just like that :( – robertp Mar 17 '11 at 16:56
  • I can... either make an array of xml elements first and cast it to XMLList or simply make a root node of XMLList and then create xml variable by taking using it's children() property. – Tintin Mar 17 '11 at 18:06
-2
var xmlList:XMLList = <><item>1</item><item>2</item><item>3</item></>;
trace(xmlList);
tptd
  • 1