XML Basics

I l @ ve RuBoard

An XML document is a text document that stores data. XML is similar to HTML because of the use of tags. However, XML differs from HTML in that HTML uses specific tags and is used for a specific purpose.

XML, on the other hand, can use a completely custom tag set and can be used for any purpose where you need data. For instance, here is a simple XML document:

 <user>     <name>Gary</name>     <ID>47</ID> </user> 

This document defines a user. A user has two pieces of information stored: name and ID.


In the preceding example, user, name, and ID are all XML elements. Each element is also known as a node. In addition, the data stored in elements are also nodes, known as text nodes.

Figure 19.1 illustrates what nodes are. In it, you see a visual representation of the preceding XML example. You can see the five nodes: user, name, ID, the text node with "Gary," and the text node with "47."

Figure 19.1. This diagram illustrates a simple XML file with three elements and two text nodes.


So why are XML documents so popular? The key is that they are both machine-readable and human-readable . Most other forms of databases are good for one or the other but not optimized for both.

XML documents can be created by people with simple text editors. Creation can also be facilitated by XML editing programs. On the other hand, programmers can easily write programs that access XML data.

Flash makes it easy to access the data in XML documents. The XML object can automatically parse an XML text document and then provide many functions and properties to access the information inside it.


It is unlikely , as a Flash programmer, that you will find a need to create an XML database for your movies. However, it is likely that you will be asked to write a Flash movie that accesses an existing XML database.

This data may take the form of a ready-made text file such as the examples later in this hour . Or, you could be calling out to CGI programs that return XML documents when queried.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net