Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » XML
Language: XML
Expertise: Beginner
Oct 28, 1999

Why Should I Use XML?

I recently bought a book that includes the XML specification as well as some commentary. Much to my surprise, I found that after authoring an XML document, the browser fed me tags as well as text. I discovered that you need to use XSL (Extensible Stylesheet Language) to get nice browser output. So now I am asking myself, "Why should I even use XML? What is it that XML is attempting to achieve?"


You have just discovered one of the great ironies of XML. The markup language was originally designed to provide a better alternative to HTML, by letting people create their own systematic markup language for specialized needs. On the way to the browser, two interesting phenomena settled out, however. First, most people have neither the time nor the resources to create their own markup language for documents. Second, by simplifying the SGML structure on which XML is based, it became increasingly apparent that it was a very useful tool for representing more structured data.

When I was new to XML, I did what most newcomers do when confronted with the language—I tried to create a Web page with it. I spent two days defining the underlying CSS styles, spent another day coding and debugging, and all for an article that would have taken me about three hours to write. What's worse is that in order to be able to support functionality that I could readily duplicate in HTML, I often had to rely on such technology as IE5 behaviors, which meant that my results didn't work in Netscape. By the time I was done with it, I asked myself exactly the same question you did, "Why did I just put myself through this malarkey? Is this really what XML is all about?"

No...it isn't. XML extends beyond documents, and even beyond data—it is a way to describe objects. An HTML document is one kind of an object—a document that contains headers, images, tables, and forms. But because we tend to think of it as browser output, we lose sight of the fact that even the simplest HTML document, described abstractly, is a remarkably complex piece of work. For the most part, serious XML developers have backed off this document outlook (for a little while, anyway) and are increasingly looking at XML as an object description language—a way to describe the properties and property values of an entity.

For example, you could describe a purchase order as an XML document. This document would be made up of a header object that maps to the general information, and collection line item objects that describe the characteristics of each item being purchased (the product name, product code, cost, number of items purchased, and so forth):

Wiley E. Coyote Acme Rocket Co. 19990909T11:25AM
Big Boom BgBm1 129.95 12 Little Boom LtBm1 49.95 16

You can send such a structure between two XML parsers located on different machines to purchase an item. You can coincidentally use XSL, XML's transformation language, to convert this output into an HTML table or with more sophisticated tools, turn it into a chart or load it into a component. However, this use is really secondary to the power of XML as a data transfer mechanism.

The books that are currently out on XML are shifting away from the document-centric viewpoint and moving toward a data-centric one. I would recommend IE5 XML by Wrox Books as a good introduction to data-centric XML, though obviously it is geared toward Microsoft's implementation of it.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date