CroftSoft / Library / Tutorials
A Brief Introduction to XML
David Wallace Croft
Senior Software Architect
CroftSoft, Inc
2001-02-20
Extensible Markup Language (XML) allows you to describe data using human readable text.
In the following example, note how each data value is encapsulated in an opening and
closing element tag pair that names the data field:
<book>
<isbn>0764506927</isbn>
<title>Learning Java through Game Programming</title>
<author>David Wallace Croft</author>
<publisher>Hungry Minds, Inc.</publisher>
<publication-date>2001</publication-date>
</book>
Those familiar with Hypertext Markup Language (HTML) will recognize the similarities.
It looks like HTML except that I have created my own element names such as "book" and
"title". HTML already defines the element "title" but here I have given it a new
semantic, or meaning, that differs within the context of my "book" definition.
Indeed, this ability to define new elements is why XML is considered "extensible".
Despite the flexibility in being able to define new element names, there are enough
constraints in the XML format that parsers do not need to be uniquely customized for
each definition. Such restrictions include a strict hierarchical nesting of elements.
For example, the following XML syntax with overlapping tag boundaries would generate
a parsing error:
<b><i>Illegal XML</b></i>
While the above may be valid in HTML, the proper way to nest the elements in XHTML
-- a definition of XML which replaces HTML -- would be as follows:
<i><b>Legal XML</b></i>
There are now hundreds, perhaps thousands, of XML definitions covering everything
from genealogy to electronic commerce. Wherever data needs to be exchanged in a
transparent manner using standard parsers that are readily available in all of the
major programming languages, XML provides a solution.
Further information on the subject of XML is easily accessible from a large number
of sources as XML has rapidly become a widely adopted technology. As a quickly
digestible introduction and handy reference book, I recommend the
XML Pocket Reference by Robert Eckstein.
© 2001 CroftSoft Inc. All rights reserved.
|