The best way to explain XQuery is this: XQuery is to XML what SQL is to database tables.

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

XQuery functions syntax

XQuery contains over 100 built-in functions. These functions can be used for string values, numeric values, date and time comparisons, node and QName operations, sequence operations, logical values, and more. You can also define your own functions in XQuery.

XQuery functions example

declare function local:minPrice($p as xs:decimal?,$d as xs:decimal?)
AS xs:decimal?
{
let $disc := ($p * $d) div 100
return ($p - $disc)
}
Below is an example of how to call the function above:
<minPrice>{local:minPrice($book/price,$book/discount)}</minPrice>