19.4. Loading XML Data with Components

Problem

You want to load XML data without having to write much ActionScript.

Solution

Use the XMLConnector component.

Discussion

XML stands for eXtensible Markup Language, which is a way of formatting data contextually for communication to and between applications. For example, an XML document may contain data you want to use within your application to populate components, URLs of images, and more. XML is formatted in a hierarchical style using tags that look similar to HTML tags. However, unlike HTML, the names of XML tags are arbitrary. Tags may be nested. In such cases you can describe the relationships between tags, or elements, as child, parent, and sibling. The following example has a parent element called book with two child nodes (that are siblings of one another) called title and authors:

	<book>
	  <title>ActionScript Cookbook</title>
	  <authors>Joey Lott</authors>
	</book>

ActionScript has an intrinsic XML class that enables you to work with XML. Although it would be misleading to suggest that working with ActionScript and XML is exceedingly difficult, there is a reasonably steep learning curve for the average Flash developer. If you want to work extensively with XML, it would be to your advantage to learn about using the ActionScript XML class, as it is a much more robust way of working with XML than a non-ActionScript solution. However, if your goal is to use XML in fairly simple ways (populating simple forms, for example) and you don’t want ...

Get Flash 8 Cookbook 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.