Hi
I would like to get the information of an xml file so that I can show it in a clip.
I can import my xml file and print out all of its data with trace() but I can’t make a simple to print the values the attributes of each node.
Here is my very simple xml file, called doc.xml
<myroot>
<person name="foo" age="18" />
<person name="bar" age="19" />
</myroot>
My loading function for the xml file works, but not the one with my loop to get the attributes values.
// LOADING OF THE XML (works well)
var loader:URLLoader = new URLLoader();
var adress:URLRequest = new URLRequest ("doc.xml");
loader.load(adress);
loader.addEventListener(Event.COMPLETE, loadXML);
function loadXML(eventObject:Event){
var xml = new XML(eventObject.target.data);
trace(xml);
}
// XML ATTRIBUTES VALUES
// error 1120: Access of undefined property xml.
function printXML(eventObject:Event){
var myarray = xml.firstChild.childNodes;
for (var i = 0; i < myarray.length; i++)
{
var current = myarray*;
trace(current);
}
}
What do I have to modify in my printXML function so that I can get in my loop the value of the attributes of each nodes?
many thanks for your help