# XML -\> Ruby mapping: is there a 'standard' approach?

**URL:** <https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445>\
**Category:** Ruby\
**Created:** [August 9, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445 "2008-08-09T16:22:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [August 9, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445/1 "2008-08-09T16:22:37Z")

</div>

Background:

I’m working on a library to read XML files and convert their contents to  
a set of Ruby objects. The XML files conform to an ASTM standard and  
there’s an XSD. The Java guys are using JAXB to generate their classes  
from the XSD. I’m not aware of an equivalent to JAXB for Ruby and so am  
going at the task manually.

Question:

Is there a standard / recommended approach, documented somewhere, that I  
could use to guide my decisions re: translating the XML structure into a  
Ruby class hierarchy?

TIA,  
Bill

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [August 9, 2008, 10:25pm UTC](https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445/2 "2008-08-09T22:25:26Z")

</div>

I don’t know much about standard approach but there are a few libraries  
out  
there which you may use like [http://roxml.rubyforge.org/](http://roxml.rubyforge.org/)

Regards  
Piyush

p.s. If you get answer for this question do put it here.

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [August 9, 2008, 10:58pm UTC](https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445/3 "2008-08-09T22:58:48Z")

</div>

Hi Piyush,

Piyush R. wrote:

> I don’t know much about standard approach but there  
> are a few libraries out there which you may use like  
> [http://roxml.rubyforge.org/](http://roxml.rubyforge.org/)

ROXML looks promising. Don’t know why Google didn’t find it for me.  
I’ll  
have to try some different queries. If you know of any more libraries  
like  
this I’d be very glad to get links.

Thanks!  
Bill

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [August 10, 2008, 1:57am UTC](https://www.ruby-forum.com/t/xml-ruby-mapping-is-there-a-standard-approach/145445/4 "2008-08-10T01:57:06Z")

</div>

On Aug 9, 10:19 am, “Bill W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Background:
> 
> I’m working on a library to read XML files and convert their contents to a set of Ruby objects. The XML files conform to an ASTM standard and there’s an XSD. The Java guys are using JAXB to generate their classes from the XSD. I’m not aware of an equivalent to JAXB for Ruby and so am going at the task manually.
> 
> Question:
> 
> Is there a standard / recommended approach, documented somewhere, that I could use to guide my decisions re: translating the XML structure into a Ruby class hierarchy?

I worked on something like this for awhile (Blow/XDK), but it felt so  
heavy and un-ruby that I let it go. Using more flexible tools like  
XML::Simple, Hpricot, Builder, and Cherry/rQuery are so much nicer.

T.
