XML vs. HTML

Tutorial
Home

What is
XML?

XML vs.
HTML

Writing
XML

Help
Psychologists?

Resources

How XML applications differ from HTML

In HTML, pieces of information are tagged in terms of how they fit in the structure of the document and how they should be formatted. Is it a heading? Or a paragraph? Should it be bold? Or italic? Is it a link? Is it part of a table? If so, is it in the first row or the second row? And so on. The following is a very simple example.

<H2>Dr. Doe's Patients</H2>
<P>John Smith<BR>
Male<BR>
34<BR>
Frequent headaches and hears voices</P>
<P>Maggie Jones<BR>
Female<BR>
31<BR>
Depression</P>

In XML, pieces of information are tagged with descriptive terms that have meaning for the context of the information. The tags identify the type of information they contain. The tags also are used to indicate a relationship between pieces of the information. The above listing of Dr. Doe's Patients, rewritten in an XML application, might look like this:

<LISTNAME>Dr. Doe's Patients</LISTNAME>
<PATIENT><NAME>John Smith</NAME>
<SEX>Male</SEX>
<AGE>34</AGE>
<COMPLAINT>Frequent headaches and hears voices</COMPLAINT></PATIENT>
<PATIENT><NAME>Maggie Jones</NAME>
<SEX>Female</SEX>
<AGE>31</AGE>
<COMPLAINT>Depression</COMPLAINT></PATIENT>

XML doesn't deal with layout and format; those aspects of document creation are handled by stylesheets. XML is meant to simply identify chunks of information in a meaningful way. Markup tags are nested within each other; inner tags are more specific identifiers of the information. Information delivered through an XML application will be more accessible and reusable than the same information delivered through HTML, because the information is given meaning through its tags.


XML and HTML: A side-by-side comparison

XML HTML
ExtensibleFixed
Subset of SGMLApplication of SGML
Can be used in various media:
The Web
Paper
CD-ROM
Audio
Can be used in one medium:
The Web
A meta-language to define markup languagesA markup language to define documents
Focus is on the informationFocus is on the structure of the document
Stylesheets are a necessityStyle sheets are an option
Closing tags cannot be omittedClosing tags can sometimes be omitted
Strengths:
Linkage
Simplicity
Portability
Intelligence
Adaptation
Maintenance
Strengths:
Linkage
Simplicity
Portability
Weaknesses:
Intelligence
Adaptation
Maintenance

XML vs. HTML Review Quiz


Helen's Home Page | Helen's PSY 422 Page