# Fast XML output

**URL:** <https://www.ruby-forum.com/t/fast-xml-output/135527>\
**Category:** Ruby\
**Created:** [April 22, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/fast-xml-output/135527 "2008-04-22T21:40:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [April 22, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/fast-xml-output/135527/1 "2008-04-22T21:40:41Z")

</div>

Hi,

we just started playing with ruby and ActiveRecord a few days ago at  
my company and we’re having major troubles of outputting xml fast  
enough.

Pure xml output from ActiveRecord::Base takes approx 20s for 500  
objects (that are small and simple). Does anyone have any pointers?  
How fast is REXML?

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [April 23, 2008, 4:30am UTC](https://www.ruby-forum.com/t/fast-xml-output/135527/2 "2008-04-23T04:30:11Z")

</div>

On Wed, 23 Apr 2008 04:40:07 +0900, Michael L. wrote:

> Hi,
> 
> we just started playing with ruby and ActiveRecord a few days ago at  
> my company and we’re having major troubles of outputting xml fast  
> enough.
> 
> Pure xml output from ActiveRecord::Base takes approx 20s for 500  
> objects (that are small and simple). Does anyone have any pointers?  
> How fast is REXML?

Slow as hell. We just did a refactoring today, going from xml to json to  
pass AR data between apps. We achieved an order of magnitude speed  
increase and profiling showed 70% of the time on the client side was  
spent parsing xml and 30% on the server side creating the xml  
reppresentation.

If you’re stuck with XML I’d look into a replacement for rexml.

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [April 23, 2008, 4:37am UTC](https://www.ruby-forum.com/t/fast-xml-output/135527/3 "2008-04-23T04:37:21Z")

</div>

On Tue, Apr 22, 2008 at 3:40 PM, Michael L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Pure xml output from ActiveRecord::Base takes approx 20s for 500  
> objects (that are small and simple). Does anyone have any pointers?  
> How fast is REXML?

Look into libxml.

–  
Avdi

Home: [http://avdi.org](http://avdi.org)  
Developer Blog: [http://avdi.org/devblog/](http://avdi.org/devblog/)  
Twitter: [http://twitter.com/avdi](http://twitter.com/avdi)  
Journal: [http://avdi.livejournal.com](http://avdi.livejournal.com)

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [April 24, 2008, 7:00am UTC](https://www.ruby-forum.com/t/fast-xml-output/135527/4 "2008-04-24T07:00:48Z")

</div>

Avdi G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Tue, Apr 22, 2008 at 3:40 PM, Michael L.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Pure xml output from ActiveRecord::Base takes approx 20s for 500  
> > objects (that are small and simple). Does anyone have any pointers?  
> > How fast is REXML?
> 
> Look into libxml.

The devil is in the details. I rewrote my XML-manipulation class to use  
libxml instead of REXML and the libxml-based version of my routine takes  
twice as long as the REXML-based version. So it all depends on exactly  
what you do with it… m.
