XML Data Type Methods page 2
The query() Method
This method basically needs an XPath expression in the XQuery parameter and returns an XML data type.
The XPath expression '/albums/album/labels/label' specifies that we want to get the first label of the second album for every single artist.
The query() method returns the XML fragment containing everything between (and including) the beginning and ending tags of that "label" element.
Let's consider another example. We need to find albums that have word "record" in description.
XPath expression in detail can be described with the following phrase: find in list of albums (albums) such an album (album), which has a description (description), that contains word "record" (contains(., "record")). A dot in function contains() refers to the current element, in this case it is description element.
We see that such an album is found only among Guns N' Roses' albums. But Radiohead has in a description of OK Computer album word "Records". This album wasn't found because XQuery is case-sensitive. To make this album be also found we'll use lower-case() function that brings the processed text to lowercase.