|
Introduction to XML in Flash
by senocular
Basic XML Structure
In looking at an example of XML, you'll notice
it looks a lot like HTML. In a way, HTML is
a type of XML (though HTML was around before
XML - both are based off of SGML).
Their structure is, in many, cases the same.
Here's a simple example of an XML file:
- <letter>
- <to>Sandy</to>
- <from>Peter</from>
- <body>I
love you!</body>
- </letter>
If you're familiar with HTML, you can see the
similarities. Like HTML, just from looking at
the above text, it's fairly easy to see what
information the file holds and how it's laid
out. Just like the italic tags <i></i>
may encase italic text in HTML, the ambiguous
<to></to> tags above surround Sandy
to indicate that Sandy is to whom this particular
letter (<letter></letter>) is to
be sent.
The information enclosed in tags in XML (and
HTML) allow for a hierarchical structure of
information. For instance, above, we knew that
Sandy is getting the letter because "Sandy"
was placed within the opening and closing to
tags and the to tags were in between the opening
and closing letter tags.
In the file-folder analogy, the letter tag
represents a folder which contains 3 other folders
to, from and body, all which are representative
of the contents or aspects of a letter. Each
one of those folders contains the given text
respective to their types (i.e. to, from or
body) which could be considered the files of
those folders.
The contents of an XML document, tags and
information within those tags, are considered
to be nodes. These nodes are the basic
building blocks XML defining all that it is.
There are two types of nodes at play in the
letter example: elements and text
nodes. Letter, to, from and body are elements;
Sandy, Peter and I love you! are text nodes.
|