Sometimes there is a need to convert a resultset into a xml file. The xml file can be shared across webservices.
I had a similar requirement but found no example online.
So I created this utility to convert resultsets into xml. The language of development is Java.
The code has provision to accept multiple resultsets. All the resultsets will be appended in the xml file.
The rows of tables can be indentified by row identifiers. Which is user supplied.
Understanding that the resultsets can be very large, I have used stax based parser to write the xml.
Amongst STAX based parsers, I have choosen WOODSTOX as my parser. Because it has very good performance ratings in various benchmark tests.
Details of Woodstox can be found here.
I have uploaded my source files in sourceforge. And can be found at the following location.
https://sourceforge.net/projects/rstoxmlwriter/
A typical usage might be:
I had a similar requirement but found no example online.
So I created this utility to convert resultsets into xml. The language of development is Java.
The code has provision to accept multiple resultsets. All the resultsets will be appended in the xml file.
The rows of tables can be indentified by row identifiers. Which is user supplied.
Understanding that the resultsets can be very large, I have used stax based parser to write the xml.
Amongst STAX based parsers, I have choosen WOODSTOX as my parser. Because it has very good performance ratings in various benchmark tests.
Details of Woodstox can be found here.
I have uploaded my source files in sourceforge. And can be found at the following location.
https://sourceforge.net/projects/rstoxmlwriter/
A typical usage might be:
for (String tableName : tableNames) {
String rowId = "row";
String query = "Select "+selectClause+" from "+table+restrictions;
ResultSet tableData = getResult(query);
XmlElementInfo xmlElementInfo = new XmlElementInfo(tableData,
rowId.toUpperCase(),table.toUpperCase());
xmlElementInfos.add(xmlElementInfo);
}
try {
new XMLWriter().writeXML(xmlElementInfos,parentTag, outputLocation+xmlFileName);
} catch (XMLWriterException e) {
e.printStackTrace();
}
closeDB();
I would be happy, if anybody finds this useful.
Also please put your comments. Let me know if there are any bugs. Let me know if there is any further enhancement requests.