Easy XML Loop question

Hello all,

I had a quick question regarding how to loop through an Object and build a formatted XML trace with the results. I think I am just missing something really small here.

In the below case, the code is supposed to loop through the object and retrieve 4 attributes.

Here is my current code:

 
on(press) {
 var my_xml2 = new XML();
 my_xml2.xmlDecl = "<?xml version=\"1.0\" ?>";
 var node = my_xml2.createElement("myclassroom"); 
 my_xml2.appendChild(node);
 node = my_xml.createElement("furniture"); 
 my_xml2.firstChild.appendChild(node);
 for (var prop in _root.itemList){
 node = my_xml2.createElement("fixture");
 my_xml2.firstChild.firstChild.appendChild(node);
 my_xml2.firstChild.firstChild.firstChild.attributes.rotation = _root.itemList[prop]._rotation;; 
 my_xml2.firstChild.firstChild.firstChild.attributes.yCoord = _root.itemList[prop]._y;
 my_xml2.firstChild.firstChild.firstChild.attributes.xCoord =  _root.itemList[prop]._x;
 my_xml2.firstChild.firstChild.firstChild.attributes.ftype = _root.itemList[prop].ftype;
 
 }
 trace(my_xml2);
}

And here are the results:

<?xml version="1.0" ?><myclassroom><furniture><fixture ftype="1" xCoord="450" yCoord="150" rotation="test" /><fixture /><fixture /><fixture /><fixture /><fixture /><fixture /><fixture /><fixture /></furniture></myclassroom>

So when looping, flash gets the first set of 4 attributes and displays them beautifully. Then it correctly shows the correct number of tags that are supposed to be there, but the attributes are blank.

If I do a:

trace(_root.itemList[prop].ftype);

all of the names show correctly.

Can anyone see anything wrong with that code?

Thanks in advance for any pointers!

44