If I have an instance of REXML::Element, is there a convenient way to
get it’s element name? I would have expected a get_name method for
Element or something like that, but according to the stdlib
documentation at http://www.ruby-doc.org/stdlib/ there is no such thing.
I found two ways that I do not like very much:
get the xpath to the element via Element.xpath and then extract the
path = el.xpath
name = path.sub(/^/(.+/)(\w)([\d*])?/ ,’\2’)
I don’t like this method since it feels wasteful.
- Use instance_eval to get the value of Element::expanded_name:
I don’t like that either (I know I’m picky) since this means to use part
of the rexml implementation that is not part of the publicly documented
Is there an other way that I would like?
Thanks in advance for all advise and insights.