| Tags
and Simple XML Tutorial
XML Tags continued
XML tags can have multiple attributes:
<a href="index.htm"
name="Home" id="001">Home Page</a>
The name of the tag is case-sensitive
in XML (but not in HTML).
<a href="index">Home</A>
wouldn't work since the "a"
and "/A" are different.
Invalid Characters
Tag names and attribute names can't
start with a number or a special character.
<2 /> is invalid
<+guy> is invalid
In fact, some characters should be
avoided most of the time when you're naming things in
XML and other languages.
You can't have a space in a name:
<my phone numbers> is invalid.
You can't start with a space:
< alpha> is invalid.
Don't use any of the following anywhere
in your name:
"$#&()<>?=@%*/|\'
These are usually fine inside attributes
or the content of the tag:
<a href="basketball.htm?id=0088">Great
Highlights!</a>
|
XML Documents
XML documents are files that end with
the .xml extension. They also start with a document
type declaration:
<?xml version="1.0" encoding="utf-8"?>
Here you can see I'm starting the
tag with an invalid character, but that means it's a
cue for the browser to consider this tag contains programming
language information. You wouldn't want to do this normally.
The XML document has one root tag.
<?xml version="1.0" encoding="utf-8"?>
<news>
<headlines>CNN</headlines>
<titles>Michael Moore's new film is controversial
</titles>
</news>
In this example, "news"
is the root tag. It's the container that all the other
tags have to be inside and that's just the way it is.
In XML, tag names and attributes can
be anything you want. Try to use descriptive names like
those above or this example:
<?xml version="1.0" encoding="utf-8"?>
<hoops>
<college>
<elite8>
<team city="Lawrence"
standings="2">Kansas</team>
<team city="LaGrange"
standings="3">Georgia Tech. </team>
<team city="Philadelphia"
standings="5">St. Joseph's</team>
<team city="Stillwater"
standings="8">Oklahoma St.</team>
<team city="Durham" standings="1">Duke</team>
<team city="Cincinatti"
standings="4">Xavier</team>
<team city="Tuscaloosa"
standings="5">Alabama</team>
<team city="New London"
standings="8">Connecticut</team>
</elite8>
</college>
<pro>
</pro>
</hoops>
>>>MORE
XML and HTML
MORE TUTORIALS
|