Re: [Flashcoders] Converting simple XML data into Array
XmlGrab might be useful if you're as2 - it's a class that loads xml and converts it into an object http://www.brandnewbox.co.uk/docs/Home/Plugin:XMLGrab/ alz On Fri, Jun 20, 2008 at 4:48 AM, Ashim D'Silva [EMAIL PROTECTED] wrote: E4X means that XML is pretty much read like an Array. So the data you mentioned would be accessed as follows: var xml:XML = [this is the variable that contains your XML]; trace(xml.file[0].text); //returns file name 1 trace(xml.file[1].text); //returns file name 2 you can also loop through with a for each for each (var i:XML in xml.file) { trace(i.text); } This is presuming AS3. There is definitely a way to do it with AS2, using nextSibling, but I can't remember off the top of my head. 2008/6/20 ACE Flash [EMAIL PROTECTED]: hey there, I was using loop to push them into Array Is there a way to convert this XML file into Array more easily? like = xml as Array? files filefile name1/file filefile name2/file filefile name3/file . /files var ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Random Lines 3D My online portfolio www.therandomlines.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Converting simple XML data into Array
This class might be helpful: http://blog.greensock.com/xmlparseras2/ I believe it does exactly what you're asking. Jack -Original Message- From: ACE Flash [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2008 6:46 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Converting simple XML data into Array hey there, I was using loop to push them into Array Is there a way to convert this XML file into Array more easily? like = xml as Array? files filefile name1/file filefile name2/file filefile name3/file . /files var ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Converting simple XML data into Array
class net.stevensacks.utils.XML2AS { public static function parse(n:Object, r:Object):Void { var a:Object, d:Object, k:Object; if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0]; else r = (a=r[k])[d=r[k].push({})-1]; if (n.hasChildNodes()) { if ((k=n.firstChild.nodeType) == 1) { r.attributes = n.attributes; for (var i:String in k=n.childNodes) XML2AS.parse(k[i], r); } else if (k == 3) { a[d] = new String(n.firstChild.nodeValue); a[d].attributes = n.attributes; } }else r.attributes = n.attributes; } } xml = new XML(); xml.ignoreWhite = true; xml.onLoad = Delegate.create(this, onLoadComplete); xml.load(path); function onLoadComplete() { var xmlObj:Object = {}; XML2AS.parse(xml.firstChild, xmlObj); var nodes:Array = xml.files[0].file; var i:Number = nodes.length; while (i--) { trace(nodes[i]); } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Converting simple XML data into Array
hey there, I was using loop to push them into Array Is there a way to convert this XML file into Array more easily? like = xml as Array? files filefile name1/file filefile name2/file filefile name3/file . /files var ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders