O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

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

Working with XML Namespaces

XML uses namespaces to prevent name conflicts in markup, with the ultimate goal of allowing markup from different XML-based vocabularies to coexist peacefully in a single document. ActionScript supports namespaces both as part of E4X and as a general programming tool. This section describes how to work with namespaces using E4X syntax but assumes prior knowledge of the concepts expressed by the W3C definition of namespaces in XML. For an introduction to namespaces in XML, see the following online resources:

Ronald Bourret's "XML Namespaces FAQ":

http://www.rpbourret.com/xml/NamespacesFAQ.htm

"Namespaces in XML 1.1" (W3C recommendation):

http://www.w3.org/TR/xml-names11/

"Plan to use XML namespaces, Part 1," by David Marston:

http://www-128.ibm.com/developerworks/library/x-nmspace.html

For information on the non-XML uses of namespaces in ActionScript programming, see Chapter 17.

Accessing Namespace-Qualified Elements and Attributes

We've already learned how to access elements and attributes not qualified by a namespace. To learn the additional techniques required to access elements and attributes qualified by a namespace, let's look at a new XML fragment example, shown in Example 18-14. The fragment depicts part of a hypothetical furniture catalog. As you read the example, pay attention to the following namespace-related items:

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