[flash 8 & as 2.0] how to loop through xml nodes

Hi all,

A couple of days ago, I started a little flash/xml project to learn how xml and flash works together. I made a XMLfile like so…


<?xml version="1.0" encoding="utf-8"?>

<data>
   <themes>
      <theme name="theme1">
         <item img="1.jpg" desc="bla" url="link1.html"/>
         <item img="2.jpg" desc="blabla" url="link2.html"/>
      </theme>
      <theme name="theme2">
         <item img="3.jpg" desc="yadda" url="link3.html"/>
         <item img="4.jpg" desc="yaddayadda" url="link4.html"/>
      </theme>
   </themes>
</data>

I’ve choosen to work with attributes, so that the XML stays clean (well, in my opinion anyway).

Now, I got my FLASHfile to load the XML successfully and with trace, I got the attributes of the first childNode (theme1). But here the thing; I can’t seem to trace the other nodes (theme2, etc.). My actionscript thusfar looks like this…


xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(loaded) {
	if(loaded) {
		parseXML();
	} else {
		trace("something went wrong; the error is: " + this.status);
	}
}
xmlData.load("myXML.xml");

function parseXML() {
	rootNode, img, desc, url;
	rootNode = xmlData.firstChild.firstChild;
	if(rootNode.hasChildNodes()) {
		for(i=0; i<rootNode.firstChild.childNodes.length; i++) {
			img = rootNode.firstChild.childNodes*.attributes.img;
			desc = rootNode.firstChild.childNodes*.attributes.desc;
			url = rootNode.firstChild.childNodes*.attributes.url;
			trace(img);
			trace(desc);
			trace(url);
		};
	}
}

Perhaps the solution is to add a second for…loop, but I’m not sure how to achieve this.
Is there anyone out there who could point me in the right direction?

Owyeah, if this question has been asked here before, I apologize…

Thanks.