From: Christian Neukirchen Date: 2006-03-28T05:18:34+09:00 Subject: Re: rexml - how to get element name "Nick Sieger" writes: > On 3/26/06, Gerald Preissler wrote: >> >> If I have an instance of REXML::Element, is there a convenient way to >> get it's element name? > > > It's in the included REXML::Namespace module: > > http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXML/Namespace.html > > element.name How can one figure that out in pure Ruby? It's rather easy, once you know the trick. irb(main):002:0> require 'rexml/document' => true irb(main):003:0> REXML::Element.instance_method(:name) => # ^^^^^^^^^^^^^^^^ irb(main):004:0> REXML::Element.instance_method(:to_s) => # ^^^^^^^^^^^ So, if you *know* you can call a method foo on objects of class Bar, but just can't find it anywere, inspect Bar.instance_method :foo and you'll see the defining module. > Cheers, > /Nick -- Christian Neukirchen http://chneukirchen.org