Reading XML

Hey guys, I am a noob loading xml data and I need to retrieve the following information:

Here’s the important/related part of the AS3:


var data:XML = new XML(loader.data as String);
            var status:String = data.*::status.toString();

            if ( status == "success" )
            {
                trace("SUCCESS");
                var ad:XMLList = data.*::ads.*::ad;
                var link:String = ad.*::link.toString();
                trace("DATA: " + data);
                trace("LINK: " + link);
 trace("AD TYPE: " + ???????) //<--- this is the line I need to correct. you will see below that it should trace "IMG"

Here’s the trace from DATA, so you can see the whole loaded data and suggest how I can go about and trace the TYPE under ADS / AD:


<response xsi:schemaLocation="http://soma.smaato.com/oapi/ http://www.smaato.com/definitions/xsd/smaatoapi_v2.xsd" xmlns="http://soma.smaato.com/oapi/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <sessionid>5831058F8B711564A3BD69C9B1C0F3B3.ip-10-0-32-201</sessionid>
  <status>success</status>
  <user>
    <id>900</id>
    <ownid/>
  </user>
  <ads>
    <ad id="0" type="IMG" width="300" height="50">
      <log-id/>
      <valid start="0" end="0" max="1"/>
      <link>http://ec2-54-209-120-163.compute-1.amazonaws.com/oapi/getAd;jsessionid=5831058F8B711564A3BD69C9B1C0F3B3.ip-10-0-32-201</link>
      <action target="http://ec2-54-209-120-163.compute-1.amazonaws.com/oapi/clickAd;jsessionid=5831058F8B711564A3BD69C9B1C0F3B3.ip-10-0-32-201" acc="server"/>
      <adtextdescription>
        <descriptionline/>
      </adtextdescription>
      <beacons>
        <beacon>http://ec2-54-209-120-163.compute-1.amazonaws.com/oapi/getBeacon;jsessionid=5831058F8B711564A3BD69C9B1C0F3B3.ip-10-0-32-201</beacon>
      </beacons>
    </ad>
  </ads>
</response>

please don’t tell me that I already know it’s an IMG so I don’t need to trace it…the TYPE will change…
Thanks a lot in advance!