From: Chris Morris Date: 2003-02-22T04:29:31+09:00 Subject: Re: [ANN] xml-configfile 0.8.0 > > It would be great if I could save and load this entire class with > > something as simple as: > > > > xml_save(addressbook, "file.xml") > > addressbook = xml_open("file.xml") > > If you want to serialize objects, YAML4R makes it quick and easy... > http://yaml4r.sourceforge.net/ And if you want XML, you can try http://clabs.org/clxmlserial.htm. Biggest thing it lacks now is it can't handle circular references. Sample: require 'cl/xmlserial' class MyClass include XmlSerialization attr_accessor :attr def initialize attr = 0 end end doc = REXML::Document.new(File.open("class.xml")) c = MyClass.from_xml(doc.root) c.attr = 60 f = File.new("class.xml", File::CREAT|File::TRUNC|File::RDWR) c.to_xml.write(f, -1) f.close yields either: 60 or: 60