Hi gang,

I'm having difficulty parsing an xml file into a multidimensional array and was wondering if anyone could see why the following isn't working... My guess is that an object variable can't be an array?



XML Sample
----------------------------------------------------------------------

<list>
        <cat id="4">
                <name>Art Glass</name>
                <notes></notes>
                <mediums>
                        <medium id="18">
                                <name>Drypoint</name>
                                <notes></notes>
                                <img>media/18_medium_tn.jpg</img>
                        </medium>
                </mediums>
        </cat>
</list>

----------------------------------------------------------------------


Actionscript
----------------------------------------------------------------------


        var arr:Array = xml.firstChild.childNodes;
        
        for(var i:Number = 0; i < arr.length; i++) {
                var item:Object = new Object();
                item.id = arr[i].attributes.id;
                item.name = arr[i].firstChild.firstChild.nodeValue;
                item.notes = arr[i].firstChild.nextSibling.firstChild.nodeValue;
                
                /***** this part isn't working *******/
                item.mediums = new Array();
                if(arr[i].firstChild.nextSibling.nextSibling.hasChildNodes()) {
                        var m:Array = 
arr[i].firstChild.nextSibling.nextSibling.childNodes;
                        for(var i_m:Number = 0; i_m < m.length; i_m++) {
                                item.mediums[item.mediums.length]['id'] = 
m[i_m].attributes.id;
item.mediums[item.mediums.length]['name'] = m [i_m].firstChild.firstChild.nodeValue; item.mediums[item.mediums.length]['notes'] = m [i_m].firstChild.nextSibling.firstChild.nodeValue; item.mediums[item.mediums.length]['img'] = m [i_m].firstChild.nextSibling.nextSibling.firstChild.nodeValue;
                        }
                }
                /***** /this part isn't working *******/
        }

----------------------------------------------------------------------


Thanks for your help guys!

Best,
Mike D


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to