A Layman's View of XML, Part 4

by Richard G. Baldwin
Baldwin's Home Page
Dateline: 12/03/99


This is the fourth in a series of articles explaining XML in layman's language, being particularly careful to avoid the use of technical jargon.

The first article in the series provided the following brief definition of XML:

XML gives us a way to create and maintain structured documents in plain text that can be rendered in a variety of different ways.
Then the article proceeded to break down the jargon into plain English and provided some examples of structured documents.

In the previous article in this series, I introduced you to tags, elements, content, and attributes. I discussed tags and attributes in some detail, and promised to take up elements and content in this article.

What is an element?

An element consists of start tag (with optional attributes), an end tag, and the content in between as shown below:

 <chapter number="1">
Content for Chapter 1

In this case, the optional attribute is colored blue and the content is colored green for clarity.

Elements can be nested inside other elements as shown below:

<chapter number="1">
Content for Chapter 1
<chapter number="2">
Content for Chapter 2

In this case, two chapter  elements are nested inside a book element. For clarity, the tags surrounding the book element are shown in blue while the tags that surround the chapter elements are shown in green.

Why does XML use elements?

It is probably fair to say that the element constitutes the fundamental unit of information in an XML document. For example, the element defines the type of information, such as chapter in our book example. Through the use of attributes, the element defines information about the information (sometimes referred to as meta information). In our book example, the number attribute provides the chapter number for each of the chapter elements. In effect, the chapter number is information about the information contained in the chapter.

Sandwiched in between the beginning tag and the end tag of an element, we find the raw information (content) that the XML document is designed to convey.

What are elements good for?

Although the topic is much to complex to present in this article, at some point, you might want to visit one of my earlier articles entitled "What is SAX, Part 1."

That article (and several subsequent articles) concentrates on how to write computer programs (using the Java language) that decompose an XML document into its elements for some useful purpose. I report that SAX is an event-based approach to XML document processing.

An event-based approach reports parsing events (such as the start and end of elements) to the program using callbacks. The program implements and registers event handlers for the different events. Code in the event handlers is designed to achieve the objective of the program.

What about content?

In my next article I will continue the discussion, including a layman's description of content.
Coming attractions...

As mentioned above, in my next article I will take up the subject of content. Tune in then for more exciting information about XML.

The XML octopus

Trying to wrap your brain around XML is sort of like trying to put an octopus in a bottle. Every time you think you have it under control, a new tentacle shows up. XML has many tentacles, reaching out in all directions. But, that's what makes it fun. As your XML host, I will do my best to lead you to the information that you need to keep the XML octopus under control. Credits This HTML page was partially produced using the WYSIWYG features of Microsoft Word 97. The images on this page were used with permission from the Microsoft Word 97 Clipart Gallery.


Copyright 2000, Richard G. Baldwin

About the author

Richard Baldwin is a college professor and private consultant whose primary focus is a combination of Java and XML. In addition to the many platform-independent benefits of Java applications, he believes that a combination of Java and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two.  He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin's Home Page