Chapter 3: Retrieving Data from XML Documents

In This Chapter

arrow Discovering XQuery

arrow Finding out about FLWOR expressions

arrow Comparing XQuery with SQL

Early in the development of XML, one of the primary concerns was the conversion of data stored in SQL databases to XML so that it could be transmitted to other, incompatible data stores or so that it could be displayed on the Web. In Book VI, Chapter 1, I describe several SQL functions whose purposes are to perform such conversions. Converting XML to SQL is also an important endeavor because SQL has traditionally been the premier tool for extracting the information you want from a collection of data. This conversion usually takes the form of shredding, in which an XML document is torn apart and pieces of it flow into the columns of tables in an SQL database. Then queries can be made by using normal SQL SELECT statements.

Querying XML documents directly, without shredding them into an SQL database, is much more complicated; thus, that capability took a while longer to implement in standard form. In addition, many common examples of XML documents aren’t readily shredded. The tree structure of an XML document can be difficult to translate into ...

Get SQL All-in-One For Dummies®, 2nd 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.