I wanted to know if anyone could tell me how to iterate through the XML nodes on a timer. An example of this would be if I had a set of sports scores and I wanted to have them show one game result after the other.
if this is my XML:
<NHL>
<Team Host="Visiting">
<Name>Dallas</Name>
<Scores>
<Total>1</Total>
</Scores>
</Team>
<Team Host="Visiting">
<Name>Detroit</Name>
<Scores>
<Total>4</Total>
</Scores>
</Team>
<Team Host="Visiting">
<Name>Pittsburgh</Name>
<Scores>
<Total>4</Total>
</Scores>
</Team>
<Team Host="Visiting">
<Name>Philadelphia</Name>
<Scores>
<Total>3</Total>
</Scores>
</Team>
</NHL>
So I want the games to come in one at a time like a sports ticker. So it would show
Dallas 1
Detroit 4
then it would wait a certain amount of time and than show:
Pittsburgh 4
Philadelphia 3
I am sure this is possible and if anyone can help it would be greatly appreciated.
Here is some code I was playing with from Kirupa to get the info from the XML I am using
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("MLB.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseSportsXML(xmlData);
}
function ParseSportsXML(SportInput:XML):void {
var GameList:XMLList = SportInput.Content.Sport.Scoreboard.Game.Team.Name.children();
var GameListAttributesH:XMLList = SportInput.Content.Sport.Scoreboard.Game.Team.(@Host == "Home").Name;
var GameListAttributesV:XMLList = SportInput.Content.Sport.Scoreboard.Game.Team.(@Host == "Visiting").Name;
for each (var GameAttributesH:XML in GameListAttributesH) {
trace("HOME " + GameAttributesH);
home.text = GameAttributesH;
}
for each (var GameAttributesV:XML in GameListAttributesV) {
trace("VISITOR " + GameAttributesV);
}
}
Thanks.