File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes ResultSet to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ResultSet to XML" Watch "ResultSet to XML" New topic

ResultSet to XML

omar bili
Ranch Hand

Joined: Aug 13, 2004
Posts: 177
hi , i need to write my ResultSet in an XML file .
any help would be appreciated
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
There was recently Another Thread about writing a result set to a report. To write XML you'd just have to add some tags around each row & column.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Omar,

Welcome to JavaRanch!

Surprisingly, I don't think there's any standard way of doing this yet. However, this article by Jeff Ryan from, found by Googling for "ResultSet to XML" strangely enough, provides a rather succinct generic solution. Remarkably simple.

Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
I dont know what you are developing, but if you use a DB you might want to explore the possibility of letting the database handle XML generation for you.
I've recently seen this done in MS SQL Server, and it was incredibly easy to do. Instead of writing Java code, just put the functionality into a SP. Has the added advantage of not needing a new software release of something has to change in retrieval of the resultset etc.

I agree. Here's the link:
subject: ResultSet to XML
It's not a secret anymore!