ActionScript 3.0 includes thorough, language-level support for XML. Not only can you create, load, and parse XML, you can write XML literals directly into ActionScript 3.0 code. A robust XML manipulation and query language, E4X, provides you with the tools to quickly and easily get the information you need. E4X, too, is implemented at the language level to make XML manipulation succinct.
XML—the eXtensible Markup Language—is a format for storing any kind of hierarchical data. It has universal adoption and countless uses. XML is designed to be minimal; as the name extensible implies, you can design your own language that uses XML for its general structure but adds on more specific grammar.
This chapter assumes a basic knowledge of XML's structure and syntax. If you are unfamiliar with XML, you may want to check out the W3C Schools XML Tutorial (
http://www.w3schools.com/xml/), the Wikipedia entry on XML (
http://en.wikipedia.org/wiki/XML), or one of the many books available on XML. Let's agree on some terminology:
<?xml version="1.0" encoding="UTF-8"?> <parentNode> <childNode attributeName="Attribute Value"> Node Content </childNode>
<childlessChildNode/> <!-- comment --> </parentNode>
The XML document begins with the document declaration and contains exactly one root node—
parentNode here. Data is represented by nodes, or elements—
childNode—enclosed within ...