Let's try to learn some basic XQuery syntax by looking at an example which is given beow.
We will use the following XML document in the example below."bookdetails.xml":
XQuery uses functions to extract the data from XML documents.
The doc() function is basically used to open the "bookdetails.xml" file:
XQuery uses path expressions to navigate through elements in the XML document.
The following path expression is used to select all the title element in the "bookdetails.xml" file:
(/bookstore selects the bookstore element, /book selects all
the book elements under the bookstore element, and /title
selects all the title element under each book element)
XQuery above will extract the following result:
XQuery uses predicates to limit the extracted data from the XML
The following predicate is used as to select all the
book elements under the bookstore element that have a price
element with a value that is less than 30:
xquery editor, xml databases, xml schema, xquery expression