Introduction | XML Data Setup | XSL and XSLT | XPath | Conclusion

XML Data Setup

Bringing the BoxesSetting up a basic xml data page is relatively simple:

Start with this:

<?xml version="1.0" encoding="ISO-8859-1"?>

Next, add the "root level" tag set. The tag can be a word of your choosing, and essentially names the database. This tag begins and ends the xml document, much in the way that the <html> tag begins and ends an html document. Choose a word that describes the group of records you will create, for example:

<Curriculum>

</Curriculum>

Next, add a record. Once again, the tag names can be of your choosing, though there are some naming rules. Be sure that the closing tag is spelled and capitalized exactly the same as the opening tag.

<Curriculum>

<class>
</class>

</Curriculum>

Now add the fields of the record:

<Curriculum>

<class>

<className></className>
<Teacher></Teacher>
<credithours></credithours>

</class>

</Curriculum>

Repeat the record entry as many times as you have records, and populate them with data:

<Curriculum>

<class>

<className>Intro to Computers</className>
<Teacher>Rhonda Lay</Teacher>
<credithours>3</credithours>

</class>

<class>

<className>HTML - Intro</className>
<Teacher>Matthew Edwards</Teacher>
<credithours>1</credithours>

</class>

</Curriculum>

It would be a lot easier to standardize the capitalization, but I have used several different schemes to illustrate the point that you can make your fieldnames upper case or lower case, but that the opening and closing tags must have exactly the same spelling and capitalization.

Save your file - call it something like firstxmlfile.xml.

See what this looks like in a browser without built-in parser.
See what this looks like in a browser with built-in parser
.
See what this looks like with a simple CSS file attached.

XML Examples from W3Schools

==>Next - XSL and XSLT