Chapter 16. How Do I Work with XML?

16.0 Introduction

XML (Extensible Markup Language) is a flexible way to structure data for storage, transmission, and parsing. Traditional name-value pairs, used by standard GET and POST form actions, are fine for transferring small amounts of simple data. However, this technique isn’t well suited for large amounts of data or when you have to carefully organize the data.

For example, name-value pairs are limited to associations that link a single value with a single variable. Complex associations where variables must be grouped in some manner are arguably impossible, or would require multiple variables with similar names.. You could get a basic database-like structure this way with name-value pairs:

?user1namefirst=John&user1namelast=Public&
user1joined=2007&user1reg=yes&

Using XML, however, you can easily associate related variables. The preceding name-value pair submission could be represented this way in XML:

<user>
    <first>John</first>
    <last>Public</last>
    <joined reg="yes">2007</joined>
</user>

You can imagine, when this data enlarges to many users, how much more easily you can work with a single variable that contains data that’s organized consistently.

Although this book discusses ActionScript 3.0’s ability to manipulate XML, it can’t delve into the basics of XML. However, you’ll find a bountiful supply of information online. One such resource is the World Wide Web Consortium home for XML coverage, http://www.w3c.org/XML/.

For the purposes of this ...

Get The ActionScript 3.0 Quick Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.