2 Replies Latest reply on Sep 18, 2007 8:58 AM by Scott McAllister

    Using AS to reference xml?

    Scott McAllister
      Can I use an ActionScript variable to reference in xml element?

      For example, I have an xml document that lists trees and their characteristics. In it's simplest form the xml looks generally like this:

      <tree id="1">
      <commonName>Birch, Paper</commonName>

      What I'm trying to do is use the name of the element to get the value between the tags. So, I would create the following AS variable:

      var filterField:String = 'drought';

      And then I want to get the value, which in this case is Medium. My attempt to do this is below, which I know does not work, but I post it to show what my though process is.

      var lastData:XMLList = _xlcTrees.source;
      trace("filterField: " + lastData[0].(child.namespace() == filterField));

      How would I get the last trace() statement to dynamically produce the value of the drought tag? Is there an easier way of going about this?