0

Here's my XML file:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <driverone>Mario Andretti</driverone>
    <drivertwo>Luigi Andretti</drivertwo>
</root>

Super simple - all I have are two names, driverone and drivertwo.

And here's my ActionScript 3:

import flash.events.Event;
import fl.controls.Label;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;

stop();

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("bulkfuel.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void
{
    myXML = new XML(e.target.data);
    trace(myXML.driverone);
    trace(myXML.drivertwo);
}

//define variable from XML data
var firstDriver:String = String(myXML.@driverone);
var coDriver:String= String(myXML.@drivertwo);

//populate text fields with variables
DriverOne_txt.text=String(firstDriver);
DriverTwo_txt.text=String(coDriver);

Everything works down to the trace function. For some reason, and I know it's stupidly simple but I just can't seem to find it, I can't get these names to load into the text fields.

1 Answer 1

1

@ - is an attribute. Use just myXML.driverone.

Sign up to request clarification or add additional context in comments.

1 Comment

And seems like OP also needs to put the last lines in to the processXML handler too..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.