Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby support for XML namespaces

I work at a small company and our production system uses a hand-rolled RESTful API, implemented in Java with JAXB. We now find that we're taking on customers who use Ruby on Rails, and I have to come up with a reference implementation to show customers how to use our API in Ruby. I'd love to be able to just tell them to use ActiveResource, but the XML required by our API uses (and absolutely requires) namespaces. Unfortunately, we've already got a number of other customers who've already integrated this API, so removing the usage of namespaces is out of the question. What's the best way to generate XML with namespaces in Ruby ?

like image 537
Alex Marshall Avatar asked Oct 29 '08 20:10

Alex Marshall


1 Answers

"Best" obviously depends on your needs.

The fastest way to generate any XML in ruby is to use libxml-ruby - link to rdoc. If your server gets any kind of load at all, this will be the way to go.

The easiest way to generate any XML in ruby is to use REXML as it's part of the standard library and therefore it "just works". If your XML generation is something that hardly ever gets used, it's probably easier to just go with rexml.

Both support XML namespaces - check the rdocs to find out how to set and get namespaces

like image 162
Orion Edwards Avatar answered Sep 28 '22 02:09

Orion Edwards