0

So I have this in an file which has been turned into a xml file. This file has an array in it, with a specific set up, like this:

<level morestuff>
    <Ground tileset = "Tiles" exportMode = "CSV">
         //info
    </Ground>
</level>

How would i got about getting

a) tileset

b) the info within the Ground tag

This is one of the first times I have used an XML file, so please excuse if this is a super simple question.

Thanks,

thor625
  • 87
  • 4
  • 16

2 Answers2

1

You can also do like this :

var xml:XML = 
    <level>
        <Ground tileset = "Tiles" exportMode = "CSV">
             some data here
        </Ground>
    </level>
;
trace(xml.Ground);      // gives : some data here

OR, when you are loading data from an external file :

var loader:URLLoader = new URLLoader();
    loader.addEventListener(
        Event.COMPLETE, 
        function(e:Event):void {
            var xml:XML = new XML(loader.data);
            trace(xml.Ground);      // gives : some data here
        }
    )
    loader.load(new URLRequest('your_xml_file.xml'));

For more infos, you can take a look on Working with XML from help.adobe.com.

Hope all that can help.

akmozo
  • 9,829
  • 3
  • 28
  • 44
0

So, i figured it out, although it may not be the simplest or best method.

I imported the flash.xml.* and used the elements() function.

I used

xmlFileName.elements("Ground");

This got everything inside the <Ground> for me.

thor625
  • 87
  • 4
  • 16