You can use XSQL , its java api provided by oracle to access the oracle database
and generate XML document as the output.
The input to this program is a sql query , and a few other parameters such as
the root element of the xml doc etc. Based on this query the program generates
XML documents. You need to use Java for writing that app and the necessary
package from Oracle.
You can download a test program from the following link , then change the
database connection and other parameters as per your need.