Sams Teach Yourself XML in 21 Days
- Table of Contents
- About the Author
- Acknowledgments
- We Want to Hear from You!
- Introduction
- Part I: At a Glance
- Day 1. Welcome to XML
- Day 2. Creating XML Documents
- Day 3. Creating Well-Formed XML Documents
- Day 4. Creating Valid XML Documents: DTDs
- Declaring Attributes in DTDs
- Day 6. Creating Valid XML Documents: XML Schemas
- Day 7. Creating Types in XML Schemas
- Part I. In Review
- Day 8. Formatting XML by Using Cascading Style Sheets
- Day 9. Formatting XML by Using XSLT
- Day 10. Working with XSL Formatting Objects
- Part II. In Review
- Part III: At a Glance
- Day 11. Extending HTML with XHTML
- Day 12. Putting XHTML to Work
- Day 13. Creating Graphics and Multimedia: SVG and SMIL
- Day 14. Handling XLinks, XPointers, and XForms
- Part III. In Review
- Part IV: At a Glance
- Day 15. Using JavaScript and XML
- Day 16. Using Java and .NET: DOM
- Day 17. Using Java and .NET: SAX
- Day 18. Working with SOAP and RDF
- Part IV. In Review
- Part V: At a Glance
- Day 19. Handling XML Data Binding
- Day 20. Working with XML and Databases
- Day 21. Handling XML in .NET
- Part V. In Review
- Appendix A. Quiz Answers
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.
Creating Well-Formed XML Documents | Next Section

Account Sign In
View your cart