A Simple XML-Based Searchable Database - The XML File and Tree
(Page 2 of 5 )
The XML File
One of the XML files used in this tutorial is shown here, starting with the XML declaration and followed by the XML tree. The XML syntax is very strict and unlike HTML is case sensitive. An opening tag (for example <models>) must be followed by a closing tag ( </models> ).
<?xml version="1.0"?>
<models>
<monica name="Monica" photo="pic_1.swf">
age: 21
eye color: dark blue
hair color: blond
height: 179 cm
weight: 185 pounds
</monica>
<heather name="Heather" photo="pic_2.swf">
age: 30
eye color: black
hair color: dark brown
height: 170 cm
weight: 145 pounds
</heather>
<kim name="Kim" photo="pic_3.swf">
age: 25
eye color: green
hair color: black
height: 163 cm
weight: 125 pounds
</kim>
<models>
You should always test if your file has the correct syntax by opening it in your browser window. A correct file will show up like this. (Note: On some servers, especially free servers, XML files may be altered.)

An incorrect file will be detected by the browser and give you a false statement. I put a file in the file collection, which has one mistake (fmodels_false.xml).
The XML Tree
An XML file has the structure of a tree as shown in the figure below.

In order to get access to individual parts of the tree using ActionScript, we have to start at the root of the tree, which in this case is the root node <models>. ActionScript is based on Microsoft´s Document Object Model (DOM). Check other tutorials in the Web for that. The principal to get access to the XML tree is basically very similar to the way to get access to the inside of a movieclip. There is a root or parent and there are children. But now let´s focus on the actual Flash file. We will mainly focus on the functions related to the XML files. There is also a preloader for pics, which however will not be discussed further in detail here.
Next: The Fla File >>
More Flash Articles
More By Joachim Schnier