FMS2 加载XML

test.xml

<?xml version="1.0" encoding="UTF-8" ?>
<TOP version="1_10">
<roomGroup>
<item num="10" room="1" name='心情故事' />
<item num="10" room="2" name='谈天说地' />
<item num="10" room="3" name='娱乐八卦' />
<item num="10" room="4" name='游戏交流' />
</roomGroup>
</TOP>

fms asc:
function loadRoom ()
{
//trace ('rid: ' + rid)
roomXML.ignoreWhite = true;
roomXML.load (__path + "/skychat/test.xml");
roomXML.onLoad = function ()
{
   var n = roomXML.childNodes [1].firstChild.childNodes;
   trace ('n: ' + n.length);
   for (var i = 0; i < n.length; i ++)
   {
    trace (n [i].attributes.name);
    application.room.push (
    {
     id : n [i].attributes.room, num : 0, name : n [i].attributes.name
    });

   }
}
}

如果是flash里var n = roomXML.childNodes [1].firstChild.childNodes;一般是var n = roomXML.firstChild.childNodes;这样也容易理解和符合规则.可FMS却通不过.如有高望指点.

 

你可能感兴趣的:(游戏,xml,Flash,八卦)