Database to xml for data migration

Hi Everyone,

I have searched google for answers and have gone down a few paths of
investigation.... But being a newbie I am rapidly getting confused and
this should essentially be a very simple task.

What I need is some advice on the best way to go about this problem.

We are needing to generate XML documents for a migration into a new
system from an existing database.

I looked into the ruby builder library, but couldn't see too many
examples outside of rails to build the XML up from a template. I know I
can put together a rails app to use an rxml template etc, but going down
that path seems to much effort for this....

I have a template of the xml I need to upload, what I need is to
populate that template for each db record. What is the simplest, best
ruby way to export from the db into xml?

Thanks for your help!

···

--
Posted via http://www.ruby-forum.com/.

A rails application would be the most suitable to generate an XML from database.
  
http://www.xml.com/pub/a/2007/01/17/making-xml-in-a-rails-app-xml-builder.html

···

Cameron Senior <cs.subscribe@gmail.com> wrote:
  Hi Everyone,

I have searched google for answers and have gone down a few paths of
investigation.... But being a newbie I am rapidly getting confused and
this should essentially be a very simple task.

What I need is some advice on the best way to go about this problem.

We are needing to generate XML documents for a migration into a new
system from an existing database.

I looked into the ruby builder library, but couldn't see too many
examples outside of rails to build the XML up from a template. I know I
can put together a rails app to use an rxml template etc, but going down
that path seems to much effort for this....

I have a template of the xml I need to upload, what I need is to
populate that template for each db record. What is the simplest, best
ruby way to export from the db into xml?

Thanks for your help!
--
Posted via http://www.ruby-forum.com/.

require "rexml/document" ;include REXML

@Skeleton = <<EOF
<anItem desc=""></anItem >
EOF

someItems= REXML::Document.new(@Skeleton)
# Then you could add an/some elements:
# Iterate here
someItems.elements['//anItem'].text = "someThing"

@drTransactionFile = File.open( "someXML.xml", "w")
@drTransactionFile.write("<topLevel >" << someItems.to_s <<
"</topLevel >"); @drTransactionFile.close

Not necessarily fast, maybe simple, doubtfully best.

MarkT

XML output may be generated from database query using DBI::Utils::XMLFormatter module.
   
  Refer Listing 5.
  http://www.oracle.com/technology/pub/articles/marx-ruby.html

···

Cameron Senior <cs.subscribe@gmail.com> wrote:
  Hi Everyone,

I have searched google for answers and have gone down a few paths of
investigation.... But being a newbie I am rapidly getting confused and
this should essentially be a very simple task.

What I need is some advice on the best way to go about this problem.

We are needing to generate XML documents for a migration into a new
system from an existing database.

I looked into the ruby builder library, but couldn't see too many
examples outside of rails to build the XML up from a template. I know I
can put together a rails app to use an rxml template etc, but going down
that path seems to much effort for this....

I have a template of the xml I need to upload, what I need is to
populate that template for each db record. What is the simplest, best
ruby way to export from the db into xml?

Thanks for your help!
--
Posted via http://www.ruby-forum.com/.

Great - thanks for the responses!

I had mostly discounted the rails option but it seems to be the best way
to control the actual output, as there is a bit of processing that needs
to be done on the data.

I just wanted to make sure I wasn't missing the easy way to do this
rather than wrap a framework like rails around a simple db export ruby
script!

thanks again.

···

--
Posted via http://www.ruby-forum.com/.

Well, if it is just a single and static template you could even use
string interpolation to do the job. Certainly faster than REXML but
YMMV.

Kind regards

robert

···

2007/12/10, cs ss <cs.subscribe@gmail.com>:

Great - thanks for the responses!

I had mostly discounted the rails option but it seems to be the best way
to control the actual output, as there is a bit of processing that needs
to be done on the data.

I just wanted to make sure I wasn't missing the easy way to do this
rather than wrap a framework like rails around a simple db export ruby
script!

--
use.inject do |as, often| as.you_can - without end