If you have to generate xml in ruby I suggest take a look at builder gems. It has really little overhead to generate xml. Take a look to this example:

require 'Builder'
xm = Builder::XmlMarkup.new( :target => $stdout , :indent => 2 )
xm.people do | p |
  p.person(:firstname => "brian", :lastname => "cardiff") do | a |
    a.cdata!("it's me!")
  p.person(:firstname => "ary", :lastname => "borenszweig")

will print in stdout

  <person lastname="cardiff" firstname="brian">
    <!--[CDATA[it's me!]]-->
  <person lastname="borenszweig" firstname="ary" />

the target parameter could be a string or file (or anything with << method).