What is the primary purpose of XQuery?
A
To validate XML documents
B
To transform XML into HTML
C
To query and extract data from XML documents
D
To display XML in a web browser
Analysis & Theory
**XQuery** is used to **query, extract, and manipulate** data from XML documents.
Which of the following best describes XQuery?
B
A SQL-like language for querying XML data
C
A CSS framework for XML
Analysis & Theory
XQuery is similar to **SQL**, but designed for **querying XML data**.
Which keyword is used to start a loop in XQuery?
Analysis & Theory
The `for` keyword is used to iterate over nodes in an XQuery expression.
What is the role of the `return` keyword in XQuery?
B
It outputs the result of a query expression
Analysis & Theory
`return` is used in XQuery to **output the result** of a loop or expression.
Which XQuery expression returns all `<title>` elements in a document?
B
doc('books.xml')/book/title
C
for $x in doc('books.xml')//title return $x
D
return title from books.xml
Analysis & Theory
`for $x in doc('books.xml')//title return $x` is a proper **XQuery loop** to return `<title>` elements.
Which function is used in XQuery to open an XML file?
Analysis & Theory
`doc('filename.xml')` is used to **load an XML document** in XQuery.
What does the `$` symbol represent in XQuery?
Analysis & Theory
`$` is used to declare **variables** in XQuery (e.g., `$x`).
Which of the following is TRUE about XQuery and XPath?
B
XQuery only works with HTML
C
XQuery builds on XPath expressions
D
XPath can’t be used inside XQuery
Analysis & Theory
**XQuery uses XPath expressions** to select nodes and data from XML.
What will the expression `count(//book)` return in XQuery?
A
The number of `<book>` elements
B
The total number of characters in the XML
D
The titles of all books
Analysis & Theory
`count(//book)` returns the **number of `<book>` elements** in the document.
Which of the following is a benefit of using XQuery?
A
It styles XML documents
B
It transforms XML into XSL
C
It provides powerful querying for large or complex XML datasets
D
It converts XML into CSS
Analysis & Theory
XQuery is great for **complex data extraction**, filtering, and **working with large XML datasets**.