is the target.data, a default structure of whole xml? in as3, should the data of xml loaded through this data itself?
function xmlDisplay(e:Event):void
{
xmlData = new XML(e.target.data);
trace(xmlData);
}
is the target.data, a default structure of whole xml? in as3, should the data of xml loaded through this data itself?
function xmlDisplay(e:Event):void
{
xmlData = new XML(e.target.data);
trace(xmlData);
}
No, e.target is a property of the Event. In this case e.target probably refers to an instance of URLLoader. Thus, e.target.data is a property of URLLoader, which holds the data received from the load operation. You then inject this data into a new XML object. The XML object parses this data to become a true XML object.
EDIT:
Well, yes: e.target.data holds the raw xml you loaded from the xml file of the website.
However, in order to access and manipulate the xml data you need to insert it into an XML object like you already do with:
xmlData = new XML( etc.. );
If this is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<root>
<image>
<id>1</id>
<url>/images/someImage.jpg</url>
</image>
<image>
<id>2</id>
<url>/images/anotherImage.jpg</url>
</image>
</root>
.. you can access the XMLNode elements like so:
trace( xmlData.image[0].id ) // outputs 1
trace( xmlData.image[0].url ) // outputs /images/someImage.jpg
trace( xmlData.image[1].id ) // outputs 2
trace( xmlData.image[1].url ) // outputs /images/anotherImage.jpg
There are many more ways to manipulate the XML. See Adobe's manual about XML for starters.
Hope this helps.