Trouble Storing XML Results in an Object

I’ve got a pretty complex XML file that I’m trying to process and I want to store all the results in one custom object. However, I’m having trouble getting past the first step. I want the object to have this basic format:

objName.XMLnodeName.value = XMLValue;
objName.XMLnodeName.attributes.XMLattribute1Name = XMLAttribute1Value;
objName.XMLnodeName.attributes.XMLattribute2Name = XMLAttribute2Value;
objName.XMLnodeName.attributes.XMLattribute3Name = XMLAttribute3Value;

so for example:
newToys.toy1.value = “XBox 360”;
newToys.toy1.attributes.color = “black”;
newToys.toy1.attributes.controllers = 2;…

I can trace through the XML file and view the results just fine - but I just can’t seem to actually store anything! Here’s a sample of my code:


function popObj(tempXML,tempObj) {
 for (var i=0; i<tempXML.childNodes.length; i++) {
  if (tempXML.childNodes*.childNodes[0].nodeValue != undefined) {
   tempObj[tempXML.childNodes*.nodeName]['value'] = new Object();
   tempObj[tempXML.childNodes*.nodeName]['value'] = tempXML.childNodes*.childNodes[0].nodeValue;
   trace("tempObj[tempXML.childNodes*.nodeName][value]: " + tempObj[tempXML.childNodes*.nodeName]['value']); // always undefined
  }
  var options = [];
  var len=0;
  for (var j in tempXML.childNodes*.attributes) {
     len++;
     options[j] = tempXML.childNodes*.attributes[j];
     trace("options[" + j + "]: " + options[j]); // haven't gotten to this part yet
  }
 
 
 
  trace("tempXML.childNodes[" +i + "].childNodes.length: " + tempXML.childNodes*.childNodes.length);
 
  if (tempXML.childNodes*.childNodes.length > 1) {
   popObj(tempXML.childNodes*,tempObj);
  }
 }
}

Any help/comments would be greatly appreciated.