In Chapter 2 we looked at what it means to query data in general and described SQL as a language for querying relational data. In this chapter we discuss the notion of querying XML (which, after all, is why you’re reading this book). XML is quite different from relational data, and it offers its own special challenges and opportunities for the query writer.
We start with the assumption that it is necessary to query the XML representation of data. You could, of course, convert XML data to some other representation (say, relational) and query that representation using some language (such as SQL). Sometimes that is the most appropriate strategy – for example, if the XML data is highly regular and will be ...