Introducing XQuery

XQuery is intended to work with single XML documents or collections of XML documents. In addition, XQuery will be able to query XML document fragments or collections of fragments. It borrows syntax from XSLT 1.0 and XPath 1.0.

For example, to query the chapter elements in a document named book.xml, we could use an XQuery expression—a path expression—such as the following:

document("book.xml")//chapter 

As you can see, an XQuery expression is not written in XML. You might recognize the use of the document() function from XSLT 1.0 and a path expression, //chapter, from XPath 1.0. Less basic XQuery expressions add XQuery-specific syntax.

XQuery is not the first attempt at an XML query language. Other such query languages include ...

Get Special Edition Using XML, 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.