Home / Tutorials / ActionScript / Loading and using XML data in AS3 /

Flash Tutorials

Loading and using XML data in AS3 - Step one: Creating an XML file

Posted by : FireCode on Jun 10, 2010

 

5.0/5

First things first. Let's look on how the XML file is structured.

<root-node>
      <child-node  ATTRIBUTE="value">value</child-node>
      < child-node ATTRIBUTE="value"> node-value</child-node>
      < child-node ATTRIBUTE="value">
    <sub-child-node ATTRIBUTE="value">sub-child-node-value </sub-child-node>
      </ child-node >
</root-node>

Each XML tag is called a node in ActionScript. The node may also have a node value , specified between the tags of the node or attributes that contain an attribute value specified within quotation marks.

Now let's see the XML file that we are going to use.

<?xml version="1.0" encoding="utf-8"?>
<example>
    <song GENRE="rock">rock.mp3</song>
<song GENRE="jazz">jazz.mp3</song>
<artist NAME="Unknown">
    <song GENRE="blues">blues.mp3</song>
</artist>
</example>

Save the text above in a file called "example.xml".

no comment

Add comment

Please login to post comments.