Sams Teach Yourself XML in 21 Days

Sams Teach Yourself XML in 21 Days

By Steven Holzner

Structuring Your Data

An XML document actually can do more than just hold your data; it can let you specify the structure of that data as well, and that's our next topic. This structuring is very important when you're dealing with complex data. For example, you could store a long account statement in HTML, but after the first ten pages or so, that data would be prone to errors. But in XML, you can actually build in the syntax rules that specify the structure of the document so that the document can be checked to make sure it's set up correctly.

This emphasis on the correctness of your data's structure is strong in XML, and it makes it easy to detect problems. In HTML, a Web author could (and frequently did) write sloppy HTML, knowing that the Web browser would take care of any syntax problems. In fact, some people estimate that 50% or more of the code in modern browsers is there to take care of sloppy HTML in Web pages. But things are different in XML. The software that reads your XML—called an XML processor—is supposed to check your document; if there's a problem, the processor is supposed to quit. It should let you know about the problem, but that's as far as it's supposed to go, according to W3C.

So how does an XML processor check your document? There are two main checks that XML processors make: checking that your document is well-formed and checking that it's valid. You'll see what these terms mean in more detail over the next few days, but you'll also take a look at them in overview here.

Share ThisShare This

Informit Network