Performing a FLWOR expression is the main use case for XQuery. It stands for:

  • for
  • let
  • where
  • order by
  • return

Which are the keywords XQuery uses to achieve it’s queries.


Syntax

books.xml

<bookstore>
	<book>
	<name>All about XML</name>
		<price>$20</price>
	</book>
	
	<book>
		<name>Learning XQuery</name>
		<price>$15</price>
	</book>
</bookstore>
Link to original

for $x in doc("books.xml")/bookstore/book  
where $x/price<20  
order by $x/title
return $x/title

This FLWOR expression reads all the titles of books with price under $, sorted by the titles.