# ROXML versus simple to\_xml

**URL:** <https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959>\
**Category:** Rails\
**Created:** [January 5, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959 "2009-01-05T21:09:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/1 "2009-01-05T21:09:14Z")

</div>

How they differ?

Does the to\_xml method of the classes array/hash/object is based on  
ROXML lib?  
As I see in [http://roxml.rubyforge.org/#quickstart](http://roxml.rubyforge.org/#quickstart), roxml needs we  
define the class (class Book in the guide) before to convert a object  
to xml. Moreover, the method to\_xml (when not using “include ROXML”)  
just accepts any existing object, what is much suitable.

I need to compare and tranfer some records between local and remote  
systems periodically. The tables (mysql) has simple varchar/integer/  
date/decimal types.  
Which type of xml mapping is recommended to achieve this task? ROXML  
or pure to\_xml method?

Thank you!

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/2 "2009-01-05T21:17:29Z")

</div>

On 5 Jan 2009, at 20:08, Tom L. wrote:

> 

roxml is trying to solve a more general problem - if you models aren’t  
activerecord models then they are not going to have a particularly  
useful to\_xml on it (the time i used it was generated xml to pass to a  
webservice)

It’s also pretty handy for parsing incoming xml.

Fred

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 9:41pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/3 "2009-01-05T21:41:01Z")

</div>

On 5 jan, 18:16, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> roxml is trying to solve a more general problem - if you models aren’t  
> activerecord models then they are not going to have a particularly  
> useful to\_xml on it (the time i used it was generated xml to pass to a  
> webservice)

Sorry my bad english. I`m not sure if I understood your answer. My model is activerecord based, but has just simple attributes (strings, integers, dates). Do you mean I don`t need ROXML in this simple case? The non-  
roxml  
to\_xml/from\_xml methods can do the job?

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 10:01pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/4 "2009-01-05T22:01:33Z")

</div>

On 5 Jan 2009, at 20:40, Tom L. wrote:

> Sorry my bad english. I`m not sure if I understood your answer. My model is activerecord based, but has just simple attributes (strings, integers, dates). Do you mean I don`t need ROXML in this simple case? The non-  
> roxml  
> to\_xml/from\_xml methods can do the job?

I would have though to\_xml/from\_xml would be quite enough here.

Fred

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 10:29pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/5 "2009-01-05T22:29:42Z")

</div>

On 5 Jan 2009, at 21:18, Tom L. wrote:

> ok, thank you very much!!  
> I will try it.
> 
> Anyway, What are the “more general problem” you said?

Just the more general case of mapping xml fragments to objects.

Fred

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [January 5, 2009, 10:19pm UTC](https://www.ruby-forum.com/t/roxml-versus-simple-to-xml/156959/6 "2009-01-05T22:19:43Z")

</div>

ok, thank you very much!!  
I will try it.

Anyway, What are the “more general problem” you said?
