XQuery tutorial

The best way to explain XQuery is to say that the relationship between XQuery and XML is equivalent to the relationship between SQL and database tables.

XQuery is designed to query XML data - not limited to XML files, but also including any data that can be presented in XML form, including databases.

The basic knowledge you should possess:

Before you continue learning, you need to have a basic understanding of the following knowledge:

  • HTML / XHTML
  • XML / XML namespace
  • XPath

If you want to learn these projects first, please visit our Home page Access these tutorials.

What is XQuery?

  • XQuery is a language for querying XML data
  • The function of XQuery for XML is similar to the function of SQL for databases
  • XQuery is built on top of XPath expressions
  • XQuery is supported by all major database engines (IBM, Oracle, Microsoft, etc.):
  • XQuery is a W3C standard.

XQuery is related to XML queries

XQuery is a language used to search for and extract elements and attributes from XML documents.

This is an example of an XQuery solution to a practical problem:

Select all CD records with prices below $10 from the CD collection stored in the XML document named cd_catalog.xml.

XQuery and XPath

XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. If you have already learned XPath, then learning XQuery will not be a problem.

You can find more information in ourXPath TutorialRead more about XPath in the

XQuery - Application examples

XQuery can be used for:

  • Extract information for use in network services
  • Generate summary reports
  • Convert XML data to XHTML
  • Search for network documents to obtain relevant information

XQuery is a W3C recommended standard

XQuery is compatible with various W3C standards, such as XML, Namespaces, XSLT, XPath, and XML Schema.

XQuery 1.0 was established as a W3C Recommendation Standard on January 23, 2007.

For more information about the W3C XQuery activity, please read our《W3C Tutorials》。