Actionscript XML Attributes to Object »

0

Tags: Actionscript

I have started to do more XML work with Actionscript 3 and found myself needing to create an object of attributes from a node. A function may already exist within Actionscript to achieve this but i couldnt instantly see it, so i quickly created one in case anyone would find it useful.

package xml.utils {
  public class XMLUtils {
    public static function attributesToObject($xml:XMLList):Object {


      var atts = new Object();


      for (var i:int=0; i«$xml.length(); i++) {
        atts[$xml[i].name().toString()] = $xml[i];
      }


      return atts;
    }
  }
}

0 responses to “Actionscript XML Attributes to Object”

leave a reply

Leave this field empty: