Saturday, September 06, 2008

[XML Parsing] Accessing Data

2: Getting the information we need

 

Replace all the code from before with this

 

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("http://83.170.89.79/~gibboco/
blog/tutorials/xml/myXML.xml"));

function LoadXML(e:Event):void
{
       xmlData = new XML(e.target.data);
       parseThis(xmlData);
}

. function parseThis(myInput:XML):void
{
      trace(myInput.tilerow[6].tilecol[2]);
}

 

This time, instead of tracing the xmlData in the LoadXML function, we call a function 'parseThis' which we send the xmlData to.

 

The above example displays the second 'tilecol' items within the sixth 'tilerow' item (shown in the pink highlighted areas).

No comments: