一般,都是读取外部的xml。有些时候,也需要动态创建xml。记得用{},包装过来的参数。

package
{
    import flash.display.Sprite;
    
    public class DymicXML extends Sprite
    {
        private var soundData:XML;
        private var urlArr:Array;
        private var nameArr:Array;
        private var lrcUrlArr:Array;
        private var artPhotosArr:Array;
        
        public function DymicXML()
        {
            initialize();
        }
        
        private function initialize():void
        {
            urlArr = ["a.mp3" , "b.mp3" , "c.mp3"];
            nameArr = ["怎么说我不爱你" , "难以启齿的柔弱" , "红色高跟鞋"];
            lrcUrlArr = ["a.lrc" , "b.lrc" , "c.lrc"];
            artPhotosArr = ["a.jpg" , "b.jpg" , "c.jpg"];
            
            soundData = new XML("<sounds></sounds>");
            
            var len:int = nameArr.length;
            for(var i:int = 0 ; i < len ; i++)
            {
                addXMLChild(urlArr[i] , nameArr[i] , lrcUrlArr[i] , artPhotosArr[i]);
            }
            trace(soundData);    
        }
        
        private function addXMLChild(url:String , name:String , lrcUrl:String , artPhotos:String):void
        {
            var xml:XML = <soundItem> 
                            <url>{url}</url>
                            <name>{name}</name>
                            <lrcUrl>{lrcUrl}</lrcUrl>
                            <artPhotos>{artPhotos}</artPhotos>
                    </soundItem>
            soundData.appendChild(xml);
        }
    }
}