XML to Database via ActiveRecord


#1

Hi all, First Post. I’m thinking of doing a Rails app where some source
data comes in from a XML file. I’d like to think there’s some lovely
abstract helper for turning an XML doc into a bunch of ActiveRecord
objects complete with one-to-manies for child nodes (object definition
assumed), although from my research REXML looks like it could do it with
some custom logic.

Is there something for this already or am I going to be the first to
produce it? :slight_smile: Thanks!


#2

The Package you want is XML::Mapping, it converts XML documents into
ruby objects, I think you just have to do a gem install xml-mapping
and follow the doc’s.

Shawn M.


#3

Shawn M. wrote:

The Package you want is XML::Mapping, it converts XML documents into
ruby objects, I think you just have to do a gem install xml-mapping
and follow the doc’s.

Shawn M.

Yes, this seems to be what I’m looking for, Not sure if I should thread
reply in a mailing list, but thanks!


#4

I’m working on one of these, too:
http://shnoo.gr/articles/2005/12/11/xmlactiverecord

– Josh

Vodex none wrote:

Shawn M. wrote:

The Package you want is XML::Mapping, it converts XML documents into
ruby objects, I think you just have to do a gem install xml-mapping
and follow the doc’s.

Shawn M.

Yes, this seems to be what I’m looking for, Not sure if I should thread
reply in a mailing list, but thanks!


#5

subimage interactive wrote:

REXML is good. I do a weekly bulk import from XML using a ruby cron job.
It
gets the job done, but it definitely isn’t as generic as you’d probably
want.

If you want to see the code email me…

Sorry for cluttering up the list, don’t have your email address (I used
the forums).

Getting XML:Mapping to play with ActiveRecord is beyond my level at this
stage, and I suspect a bulk import’d be more effecive in any case.
Please email the code (or whatever) to removed_email_address@domain.invalid,
thx muchly.


#6

REXML is good. I do a weekly bulk import from XML using a ruby cron job.
It
gets the job done, but it definitely isn’t as generic as you’d probably
want.

If you want to see the code email me…