Word 2007[c] The Missing Manual

15.1. What's XML and Why Should I Care?

Almost 400 years ago, the English poet John Donne proclaimed, "No man is an island." What would he think today with everyone tethered to each other over computer networks? Yet, in spite of all the connections, it's still hard to share information. Different computers and different programs speak different languages. Expert programmers have spent years trying to make Macs and PCs communicate, and they still haven't fully succeeded. So imagine how much more of a challenge it is to get PCs to talk to those big computers at banks, insurance companies, and airline reservation desks. XML offers a way for all these machines and their programs to pass bits and pieces of information back and forth.

15.1.1. How XML Works

The basic idea behind XML is pretty simple. In XML, descriptive tags are placed around a piece of information, like so:

<TITLE>A Tale of Two Cities</TITLE>

That way, any program (or even a perceptive human) can see that the information inside the tags is a title. So, a program at a bookstore may plug this title information into a sales and inventory database, while a Word document at a publishing house may insert the same information into a press release to promote the book. (See the box below for a quick course in tags.)

UP TO SPEED

XML & HTML's Common Ancestors

If the XML tags such as this one, <title>A Tale of Two Cities</title>, look familiar, you've probably dabbled in HTML, the language that's used to define pages on the Web. There's a good reason why XML and HTML documents look similarthey share a common ancestor , SGML (Standard Generalized Markup Language). All these languages use similar tags to mark up documents, but they were created for different jobs. SGML was designed to do just about anything, but it's so complicated and difficult that it doesn't see much use.

XML and HTML have more modest goals, so they're not only easy to use, but they're also being used more and more all the time. HTML is designed to format information sent over the Internet so that it can be viewed as pages. XML was developed for sharing information between different computer systems and programs.

  • HTML stands for Hypertext Markup Language. In computer lingo, hypertext is text with links. By clicking these links, you travel from one document to another. HTML is the language that defines the links in hypertext. It also describes formatting for the text and links pictures and other media to Web pages.

  • XML serves a different function. Instead of describing the way a document looks, XML describes the information within a document. For example, markup tags in XML wrap around a word, a number, or a paragraph. They say, "This is the company name ," "this is the telephone number," "this is a stock quote," and "this is a rhinoceros." Of course, you know what, say, a telephone number looks like, but XML's purpose isn't to tell humans about the telephone number; its purpose is to tell other programs and other computers about the telephone number. XML describes the parts of a document so that another program can identify those parts and then use them.

15.1.2. The Advantages of XML

As a way of sharing information between people and computers, XML has a lot of advantages over the files created by a specific program like Word, Excel, or Access. Here are some of the advantages:

  • XML can be read by humans . There's no real mystery behind XML documentsthey're based on standard text. So, if you need to, you can read a document with XML code and figure out what kind of information it contains. If you're so inclined, you can even make simple edits using a program like Notepad or Wordpad.

  • XML documents can be easily sent over the Internet or over a business network . Because they're just text files, it's just as easy to send an XML document over the Internet or an internal company network as it is to send a Web page.

  • XML files aren't tied to a particular operating system or any particular program . It's not difficult to write a program that can read an XML file and use the information inside. (Well, it's not difficult for people who know how to write programs.) Programs are available for just about every type of computer around today. Equally important, years from now programs will exist for Windows 2027 and Mac OS XXX that can read and use XML files and information.

  • XML isn't owned by any one company . Microsoft doesn't own the XML standard and neither does any other company. It's free to use XML in a new program or to use it on your computer network.

Категории