package com.exanimo.utils { /** * * .. * * @langversion ActionScript 3 * @playerversion Flash 9.0.0 * * @author Matthew Tretter * @since 2008.03.17 * */ public class XMLUtil { /** * * */ public function XMLUtil() { throw new Error('XMLUtil contains static utility methods and cannot be instantialized.'); } // // public methods // /** * * Converts XML attributes into nodes. * */ public static function expandAttributes(xml:XML):XML { var result:XML = xml.copy(); XMLUtil._expandAttributes(result); return result; } /** * * * */ private static function _expandAttributes(xml:XML):void { var index:uint = 0; for each (var attr:XML in xml.attributes()) { var name:String = attr.name(); var value:String = attr.toString(); var newNode:XML = <{name}>{value}; if (xml.*.length()) { xml.insertChildBefore(xml.*[index], newNode); } else { xml.appendChild(newNode); } index++; } delete xml.@*; for each (var child:XML in xml.*) { XMLUtil._expandAttributes(child); } } } }