senderista / hotmail.com (Tobin Baker) wrote:
> Are there any Ruby analogs of these two Python modules (xml_pickle,
> xml_objectify)?  Couldn't find anything on the RAA.
> 
> xml_pickle:
> http://www-106.ibm.com/developerworks/library/xml-matters1/index.html
> 
> xml_objectify:
> http://www-106.ibm.com/developerworks/library/xml-matters2/index.html

How about XMarshal?

http://www.goto.info.waseda.ac.jp/~fukusima/ruby/xmarshal.html
http://www.goto.info.waseda.ac.jp/~fukusima/ruby/xmarshal.rb


## xmarshal_sample.rb
require 'xmarshal.rb'
class Foo
  def a(val)
    @a = val
  end
  def b(val)
    @b = val
  end
  def c(val)
    @c = val
  end
end

foo = Foo.new()
foo.a(1)
foo.b("foo")
foo.c([1,2,3,{"a"=>"b","c"=>"d"}])
print XMarshal.dump(foo)


Result:

<?xml version="1.0" encoding="UTF-8"?>
<RubyObject version="1.0">
  <Foo>
    <a type="Integer">1</a>
    <b>foo</b>
    <c type="Array">
      <Integer>1</Integer>
      <Integer>2</Integer>
      <Integer>3</Integer>
      <Hash>
        <String key="a">b</String>
        <String key="c">d</String>
      </Hash>
    </c>
  </Foo>
</RubyObject>


Regards,

TAKAHASHI 'Maki' Masayoshi     E-mail: maki / open-news.com