0 Replies Latest reply on Mar 1, 2007 1:22 PM by germanHernandez

    XML recursive function

    germanHernandez
      Hi, I've been trying to create a recursive XML parser, and been partly succesful with it. I've already been able to parse the xml with the next code:

      private function mParseXML(xmlToParse) {
      for (var n in xmlToParse.childNodes) {
      var tempObj:Object = new Object();
      tempObj["type"] = xmlToParse.childNodes[n].nodeName;
      for (var m in xmlToParse.childNodes[n].attributes) {
      tempObj[m] = xmlToParse.childNodes[n].attributes[m];
      }
      if (xmlToParse.childNodes[n].nodeName == "menu") {
      mParseXML(xmlToParse.childNodes[n]);
      }
      }
      }

      but I haven't been able to save the information in an useful way. What I'm trying to achieve is at the end have an array with the same structure of the xml and access the attibutes with dot notation for example:
      trace(_xmlArray[0][2].name)
      Thanks a lot for your help.
      German Hernandez