Javatpoint Logo
Javatpoint Logo

XQuery HTML Format

XQuery can also be used to transform an XML document into an HTML page.

Let's take an example to see how it works:

XQuery HTML Format Example

Let's take an XML file named "books.xml", having the following code.

XML statement:


XQuery Expression:


This example will select all the title elements under the book elements that are under the bookstore element, and return the title elements in alphabetical order.

Now, create a Java based XQuery executor program to read the books.xqy, passes it to the XQuery expression processor, and executes the expression. After that the result will be displayed.

Execute XQuery against XML

Put the above three files to a same location. We put them on desktop in a folder name XQuery4. Compile using console. You must have JDK 1.5 or later installed on your computer and classpaths are configured.




java XQueryTester


XQUERY Html format 1

If you want to eliminate the title element and show only the data inside the title element, use the following XQuery expression:



XQUERY Html format 2
Next TopicXQuery XPath

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA