Learn the simple rules of XML.
Defining an XML File
XML is a very easy language to use and maintain. There
are just a few steps to follow to successfully make
an XML file. The first thing to do is do define the
document as an XML file. An XML file doesn't have
to end in a .xml entension, all it needs is the first
line to be:
<?xml version="1.0"
encoding="utf-8"?>
|
Closing and Opening Tags
It is safe to say that that the line above is the only
thing in XML that doesn't need a closing tag. Unlike
HTML, every tag you make in the XML file needs an
open and closing tag. You can make up any type of
a name for the type, as long as you open and close
it. This includes any tag you might want to make
for images, links, etc. For instance, in the following
code, see how the spoono tag is opened and closed?:
Tags are Case Sensitive
Unlike HTML, XML tags are case-sensitive and defining
one doesn't mean the same as the other. For instance,
this would give you an error:
Nesting
Every tag must be inside the root element tag which
must encompass all the other sub-elements. This pretty
much means that in our script, all the coding we
do must be inside the <spoono></spoono> and
you can't have multiple instance of the spoono tag.
Everything must be nested inside this immense spoono
tag. Also, tags must be closed in the reciprocating
order as they are open. For example:
<spoono>
<title><b>Spoono Rocks</b></title>
<news>I'm writing a tutorial</news>
</spoono>
|
Attributes
In any given tag, you're allowed to have as many attributes
as you want. To give an example of an attribute,
the
"href" in the "a" tag of an HTML
link is an attribute. So is the "src" in
an
"image" tag, etc. All the attribute values
inside the tag must be in quotes. For example:
<spoono>
<title type="post"><b>Spoono
Rocks</b></title>
<news author="Akash Goel" date="9/1/03">I'm
writing a tutorial!</news>
</spoono>
|
Conclusion
As you can see, there aren't too many rules to follow
for writing XML code. It is really the parser for
XML which has to do the grunt work by reading the
XML file and making it look useable to a viewer.
If you have any questions, feel free to post on the
discussion board by clicking the link below and someone
will be sure to help.
|