Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet to XML

 
omar bili
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi , i need to write my ResultSet in an XML file .
any help would be appreciated
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 developer.com, found by Googling for "ResultSet to XML" strangely enough, provides a rather succinct generic solution. Remarkably simple.

Jules
 
Maarten Vergouwen
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

rgds,
Maarten
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic