User Guide
312 Working with XML
A quick introduction to XML
This chapter assumes that you are familiar with basic XML concepts. However, even if you are
new to XML, you may be able to get started working with basic XML methods by using the
information in this chapter. As a basic introduction, consider the following XML document:
<order xmlns = "http://www.example.com/xml">
<book ISBN="0942407296">
<title>Baking Extravagant Pastries with Kumquats</title>
<author>
<lastName>Contino</lastName>
<firstName>Chuck</firstName>
</author>
<pageCount>238</pageCount>
</book>
<book ISBN="0865436401">
<title>Emu Care and Breeding</title>
<editor>
<lastName>Case</lastName>
<firstName>Justin</firstName>
</editor>
<pageCount>115</pageCount>
</book>
</order>
This document contains two book elements (also known as nodes). The first book element has
three child elements, with the names
title, author, and pageCount; the author element has
two child elements. The first
book element has an ISBN attribute (with the value
"0942407296"). The content of the first book element is its collection of child elements. The
content of the
firstName element is the text "Chuck". The entire XML document has a
default namespace, defined at the fictitious URL http://www.example.com/xml. This
namespace defines the schema for this type of XML document.
ActionScript 3.0 includes new operators—such as the dot (
.) and attribute identifier (@)
operators in the following example—for working with XML data. If you assign the previous
sample XML data to an object named
order1, the following statements are valid code:
trace(order1.book[0].author.firstName); // Chuck
trace(order1.book.(@ISBN=="0865436401").pageCount; // 115
delete order1.book[0];
The new operators and other new E4X classes, methods, and properties are discussed in this
chapter.