XQuery Add is used for adding elements, attributes, HTML elements and text in the results from the input documents.
Let's understand it by using an example.
Take an XML file named books.xml, having the following data.
Immortals of Meluha Amish 2010 180 Harry Potter J K. Rowling 2005 300 Let's C Yashwant Kanetkar 2003 200
for $x in doc("books.xml")/bookstore/book/title order by $x return $x
Now this XQuery expression will return the title elements in the same manner as they are described in the input document.
Now you can add your own elements and attributes to the result.
If you want to add some HTML elements to the result, use the XQuery like this: