Retrieving XML data with variables

Hi everyone,

I’m not even sure if this is possible, but I’m looking to retrieve a string from an embedded XML file, using a variable as the XML element’s name. Here’s what my code currently looks like, although it doesn’t quite work:


private final function getAreaTitle(_index:int):String
{
    var _element:String = map_XML.mapnode.@title[_index];
    // This gives us "title_training"

    return text_XML._element;
    // ie. return text_XML.title_training;
}

I’m not massively familiar with the XML format, so apologies if I’ve not explained myself very well. As you can hopefully see, I have one XML file containing my map data and another containing my text, such as area titles and locations. What I’m trying to retrieve in the example above is the string with the label “title_training” from the “text_XML” file. Of course, the function should be able to return the title for any area, so I need to find a way of converting “_element” in to the right format - does anyone know if this is possible?

Cheers,

Mike.