XQuery: Return value of an element rather the element itself XQuery: Return value of an element rather the element itself xml xml

XQuery: Return value of an element rather the element itself


Yes, you want the text() function for selecting the child text:

return $xml/text()

Be careful if you will have nested tag structure inside $xml though, because this will only go one level deep for text nodes. If you want all of the text nodes together, stripping out other XML structure, this will do arbitrarily deep:

return $xml//text()


Use the string function to get the string content of a node.

return string($xml)


To return only the data inside an element you can use:

return data($xml)