Including elements from the input document
File: Data.xml <order> <car model="A"> <name language="en">name 1</name> </car> <car model="B"> <name language="en">name 2</name> </car> <car model="B"> <name language="en">name 3</name> </car> </order> File: Query.xquery for $prod in doc("Data.xml")/order/car[@model = 'A'] return $prod/name Output: <?xml version="1.0" encoding="UTF-8"?> <name language="en">name 1</name>