# XML to Database via ActiveRecord

**URL:** <https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064>\
**Category:** Rails\
**Created:** [December 12, 2005, 7:48pm UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064 "2005-12-12T19:48:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 12, 2005, 7:48pm UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/1 "2005-12-12T19:48:01Z")

</div>

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? 🙂 Thanks!

---

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 12, 2005, 7:58pm UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/2 "2005-12-12T19:58:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 13, 2005, 8:04pm UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/3 "2005-12-13T20:04:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 13, 2005, 10:34pm UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/4 "2005-12-13T22:34:22Z")

</div>

I’m working on one of these, too:  
[http://shnoo.gr/articles/2005/12/11/xmlactiverecord](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!

---

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 18, 2005, 10:48am UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/5 "2005-12-18T10:48:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vodex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vodex](https://www.ruby-forum.com/u/vodex)\
**Post date:** [December 14, 2005, 12:04am UTC](https://www.ruby-forum.com/t/xml-to-database-via-activerecord/50064/6 "2005-12-14T00:04:06Z")

</div>

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…
