I'm experimenting with this XML2RB [1]. The idea is to generate
a DSL for a class of XML files (from a bunch of XML files).
Each XML file in this class can be translated to a Ruby script,
which can be executed with the DSL. Running a script actually
builds the tree by default, including the classes and methods
as you mentioned. Each class can optionally be enriched with
new functionality.

All examples are real, but I've not yet released any code.
Untill now, it's just an experiment.

The document will grow every now and then. It's not static.

gegroet,
Erik V. - http://www.erikveen.dds.nl/

 [1] http://www.erikveen.dds.nl/xml2rb/index.html