XQuery TutorialLesson 67Free preview
XQuery Example
This lesson is part of XML · All levels
Summary
The XQuery query works by selecting nodes from XML documents using XPath expressions, e.g. doc("cd.xml")/catalog/cd) and then filtering with a predicate. The result of the query is a sequence node or value that can be directly rendered. This basic example-example shows how to pull the title, price, or entire CD element.
Key points
- Doc() opens the XML document as a query input
- A line like /catalog/cd selects a set of elements (sequence)
- The predicate [price>10] filters the node based on the condition
- The result is a sequence, it can be a node, a number, or a text.
- Expressions can be written inline or stored as a file .xq
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.