• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ResultSet to XML

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi , i need to write my ResultSet in an XML file .
any help would be appreciated
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic