XML and/or XMLDocument and parsing

Im trying to figure out wether to use XML or/and XMLDocument and how to parse it so it becomes easily accessible. Final use will be a menu list with buttons loading .swf files. Im starting with a simple listmenu.xml something like

<?xml version="1.0" encoding="utf-8"?>
<menulist>
 
 <menuitem itemname="home" link="test.swf" main="true">
  <sub type="font">arial</sub>
  <sub type="italic">true</sub>
  <sub type="bold">true</sub>
 </menuitem>
 
 <menuitem itemname="about" link="test2.swf">
  <sub type="font">times</sub>
 </menuitem>
 
 <menuitem itemname="contact" link="test3.swf">
  <sub type="font">times</sub>
 </menuitem>
 
</menulist>

I use both attributes and childs, not for any particular reason though.
Now I created a .as class creating a XML object, works ok.

 
package classes.listmenu {
//start of package
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.net.URLLoader;
 import flash.net.URLRequest;
 
     import flash.xml.XMLDocument;
     import flash.xml.XMLNode;
     import flash.xml.XMLNodeType;
 
 public class comp extends Sprite{
 //start of class
 
  //----------parameters------------
  public var maskheight:Number = 100;
  public var maskwidth:Number = 200;
  //-----------internal-------------
  public var menuData = new XML();
  //---------------------------------
 
  public function comp() {
   cleanup();
   loadxml();
   addEventListener(Event.ENTER_FRAME, dononstop, false, 0, true);
  }
 
  //---------------------------------
  function cleanup(){
   for(;numChildren>0;){
    removeChildAt(0);
   }
  }
  //---------------------------------
 
  public function loadxml(){
   var loader:URLLoader;
   loader = new URLLoader();
   loader.addEventListener(Event.COMPLETE, xmlLoaded);
 
   var request:URLRequest = new URLRequest("listmenu.xml");
   loader.load(request);
   function xmlLoaded(event:Event):void {
    var myXML:XML = new XML(loader.data);
 
    //later added
    var myXMLdoc:XMLDocument = new XMLDocument();
    myXMLdoc.ignoreWhite = true;
    myXMLdoc.parseXML(myXML);
    var xmldata = new Array([],[],[]);
    var Node = myXMLdoc.firstChild;
    for(n=0;n<Node.childNodes.length;n++){
     for(nn=0;nn<Node.childNodes[n].childNodes.length;nn++){
      xmldata[nn][n] =  Node.childNodes[n].childNodes[nn].childNodes[0];
     }   
    }
 
    //
   }
  }
 
  //---------------------------------
  public function dononstop(e:Event):void {
  }
  //---------------------------------
 
 //end of class
 }
//end of package
}

Now I haven’t managed to read the number of items from the XML so I also created the XMLDocument and started pouring everything in an array. It’s because need to read Node.childNodes.length to be able to generate X number of menubuttons
My main concern is -> is this nessesary? I basically have XMLDocument, duplicate from XML… Seems a bit inefficient. No?

Further; the list menu will have between 100 and 500 items so I plan to have a number of functions() to re-create the list in several ways (for example showing main-marked true only, and also showing the list based upon user search field input). So that’s where I think the array will be useful. Or should I use a Dictionary???

Anyway, Ive started to put &lt;sub&gt;child values into a main array "xmldata" but haven't yet found out how to put attributes as well. Should I forget about attributes and transform them into &lt;sub&gt;child values instead? Because Im still at the beginning, I hope to get some responses to avoid major issues later.
Summing up;

  • XML with attributes only?
  • or XMLDocument with child <sub>s only?
  • or both?
  • and organize everything into a Array or Dictionary or is that unnessesary?
    Share your thoughts?