Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating XML from SQL

 
Brian Grey
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to generate an XML document from a SQL query. Is there a tool that do it easily? How should I do it?

1st step: retrieve the data
....
conn = getConnection();
query = "SELECT * FROM CLIENT";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
....
2nd step: generate the XML file

I have no idea how to do it. I need your help.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 3: Profit!

Seriously, you would build up an in-memory DOM using the data you retrieve, then serialize it to the XML file. I am assuming that you are also planning on auto-generating the element names from database and column metadata?

In any case, this is much more of an XML issue than a JDBC one, so I'm going to transfer this over to the XML forum for further discussion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic