Chapter 15. SQL and XML

This overview does not attempt to cover the whole topic of XML; rather, its purpose is to introduce XML to those who may be unfamiliar with it, and to highlight a few aspects of it that may be of interest to the readers of SQL Bible.

Introduction

XML is a popular language of information exchange and is on its way to becoming the de facto standard. Although it is approaching its tenth birthday, its power is still being explored and increased.

The versatility of XML comes from its venerable predecessor, SGML. The original SGML (Standard Generalized Markup Language) was conceived as a means for representing text documents in electronic form. One of its prominent properties was the ability to mark up fragments of text with special tags for various purposes.

XML (eXtensible Markup Language) still uses tags extensively — more extensively, in fact, than SGML, but uses them to establish structure, as opposed to simply mark up text between two tags. Furthermore, XML does not confine itself to any particular, predefined set of tags, as SGML does; any string, within certain syntactic confines, may serve as a tag. On the other hand, in XML, a tag must have a matching end tag; otherwise, a piece of XML is said to be "not well-formed," and cannot be parsed by an XML parser.

The Structure of XML

A well-formed XML document has a tree structure (or forest structure for more complex composite documents). Usually, at the nodes of the tree are elements (although there also could be ...

Get SQL Bible, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.