Introduction to XQuery
The best way to explain XQuery is this: XQuery's relationship to XML is the same as SQL's relationship to database tables.
XQuery is designed to query XML data—not just XML files, but any data that can be represented in XML format, including databases.
Prerequisites:
Before you continue, you should have a basic understanding of the following:
- HTML / XHTML
- XML / XML Namespaces
- XPath
If you wish to learn these topics first, please visit our homepage for tutorials.
What is XQuery?
| | XQuery is a language for querying XML data<br>XQuery is to XML what SQL is to databases<br>XQuery is built on XPath expressions<br>XQuery is supported by all major database engines (IBM, Oracle, Microsoft, etc.)<br>XQuery is a W3C standard |
XQuery and XML Query
XQuery is a language used to find and extract elements and attributes from XML documents.
Here is an example of a practical problem solved by XQuery:
"Select all CD records with prices below $10 from an XML document named cd_catalog.xml."
XQuery vs. XPath
XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. If you have learned XPath, learning XQuery will be straightforward.
You can read more about XPath in our XPath Tutorial.
XQuery - Application Examples
XQuery can be used for:
- Extracting information for use in web services
- Generating summary reports
- Converting XML data to XHTML
- Searching web documents for relevant information
XQuery is a W3C Recommendation
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 on January 23, 2007.
For more information about W3C's XQuery activities, please read our W3C Tutorial.