This is an archived tutorial from the kirupa.com legacy collection. It covers software that may no longer be available, but it is kept online because the ideas still hold up.
Before making/editing XML, lets first learn what it is. That begins with understanding why XML is; why does it exist? Basically, XML was created to serve as an easily usable, readable method to format information within an basic text file. What it does is allows you to contain information (text/numbers) in a hierarchal manner. This means one bit of information can serve as a type of file folder for holding more information.
In fact, you can think of XML just as that, as a text write-out of a hierarchical file system. It is NOT a script and does NOT "do" anything. It just provides information in an outlined and logically laid out manner.
For more information beyond laymens terms,
see:
http://www.xml.com/
http://www.w3.org/XML/
XML structure
Looking at XML, you'll notice it looks a lot like HTML. In a
way, HTML is a type of XML (though it was around before XML
was) but the structure is in many cases the same. Here's a
simple example of an XML file:
<LETTER>
<TO>Sandy</TO>
<FROM>Joseph</FROM>
<BODY>I love you!</BODY>
</LETTER>
Its fairly easy to see what information this
XML file holds and how its laid out. In the file folder
metaphor, this represents a folder called LETTER which
contains 3 other folders TO, FROM and BODY. Each one of
those folders contains the given text. The folder TO for
example has "Sandy" in it.
The XML itself is made up primarily of 2 things, Nodes and
Attributes. Each one of these are containers for
information, though attributes are special in that they are
contained only within nodes. In the example above, each one
of the 'folders' (ie LETTER, TO, etc.) are a node. Nodes, as
the name suggests, are containers which can hold textual
information (in Attributes) as well as have within them
other nodes as seen above. Its this encapsulation which
makes up the hierarchy of a XML file defining its structure.
There are no attributes in the LETTER XML example, and often
attributes aren't used at all. However, they can be useful
in specifying properties or little tid-bits of information
within a given node. Here is an example that uses
attributes:
<THURSDAY>
<MEETING TIME="10:00">
The meeting was boring. I made paper airplanes with a memo I recieved earlier.
</MEETING>
<LUNCH TIME="1:30">
John came over to talk to me. He smells funny today.
<SERVED MAINCOURSE="Steak" SIDE1="Apple" SIDE2="Mustard" DRINK="TANG" />
<SPENT MEALCARD="0" CASH="12.00" />
</LUNCH>
</THURSDAY>
MEETING, for example, contains the attribute
TIME. TIME's value is 10:00. In HTML attributes would be
like the href or target options within an anchor
<a></a> tag.
TIME just gives you a way to specify some extra information
which is associated directly with that node.
The above example demonstrates two other things:
Nodes with out any child nodes, or nodes
within it, can be terminated within their own tag using />
instead of re-writing the tag over again in closing tag. For
example,
<NODE1></NODE1> can be instead be written as
<NODE1/>.
This is seen with the SERVED and SPENT nodes within LUNCH.
You can see how the text in the LUNCH node - "John came over to talk to me. He smells funny today." - sits pleasantly with the other nodes SERVED and SPENT. This is because that text is itself a node. Its a text node. It doesn't have any bracket tags nor any attributes or child nodes (folders in itself). All it is is just text - its a text node! The first example also had text nodes. "Sandy", "Joseph" and "I love you!" were all text nodes. Non-text nodes can also be referred to as "Elements".
Hopefully, for those of you who didn't know anything or knew little about XML, this cleared some things up or gave you an idea on how to perceive XML. Feel free to post any questions you may have on the forums.
That wraps up this tutorial. A huge thank you to all of you who buy kirupa's books, became a paid subscriber, watch the videos, and/or interact on the forums. Your support is what keeps writing like this online! 😇
This tutorial was written by senocular, also known as Trevor McCauley. He has been one of this community's most generous teachers since the early Flash days, and he is still around: find him on senocular.com and on the forums.
:: Copyright KIRUPA 2026 //--