Quantcast

XQuery is to XML what SQL is to database tables and is being widely used in association with XML for web programming. Prior knowledge of HTML and XML is required to have a firm grip on XQuery. XQuery is mainly designed to query XML data – not just XML files, but anything that can appear as XML, including databases. Good thing about xQuery is that it is supported by all major databases. To put it in simple words, XQuery is a language for finding and extracting elements and attributes from XML documents. Some of the common uses of XQuery could be to extract information to use in a Web Service, to generate summary reports, to transform XML data to XHTML and to search Web documents for relevant information. XQuery is compatible with several W3C standards, such as XML, Namespaces, XSLT, XPath, and XML Schema.

Let’s tackle XQuery with an example whose separate parts we would analyze later. Example:

In the above example, The doc() function is used to open the “books.xml” file. So, functions are an integral part of an XQuery document.

Another important aspect is Path Expressions, which are used to navigate through elements in an XML document. In the above example, the following path expression is used to select all the title elements in the “books.xml” file:

The XQuery above will extract the following:

Finally, Predicates are used to limit the extracted data from XML documents. For example, following predicate is used in the above code:

This XQuery will extract the following:

Due to its multi dimensional yet simple features, XQuery is increasingly used in web programming. Good thing is, you can learn it within days if you have a prior knowledge of XML. We would discuss some more aspects of XQuery in a future article.

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Admin
Admin
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.