O'Reilly logo

ActionScript 3.0 Cookbook by Joey Lott, Darron Schall, Keith Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding XML Structure (Reading and Writing XML)

Problem

You want to understand how to read or write XML.

Solution

XML is tag-based and hierarchical. If you are familiar with HTML, learning the basics of XML should not be very difficult.

Discussion

Although reading and writing good XML is not a skill that is specific to ActionScript, it is, nonetheless, a skill from which your ActionScript can benefit. If you are not yet familiar with XML, don’t worry. This is going to be painless.

XML is a way of representing structured data. This means that you explicitly define the context for the data. For example, without XML you might have a string of data such as:

Jerry,Carolyn,Laura

You can use XML to tell us who these people are:

<family>
  <father>Jerry</father>
  <mother>Carolyn</mother>
  <sister>Laura</sister>
</family>

Now, as you can see, the XML tells us a lot more about the data. Here are a few other points to notice about XML:

  • XML is composed mainly of nodes. A node is a general term that can refer to many parts within the XML. For example, <family> is a node in the preceding XML snippet; these nodes are called elements. Also, the values Jerry, Carolyn, and Laura are nodes; these nodes are called text nodes.

  • Every XML element must have a matching opening and closing tag. The opening tag might look like <family>, and the closing tag is identical, except that it uses a forward slash to indicate it is closing the element, as in </family>. The opening and closing tags can be combined if the element ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required