class REXML::Element
def xpath
e.xpath # => "foo"
e = REXML::Element.new('foo')
If there is no parent, returns the expanded name of the element:
c.xpath # => "/a/b/c"
b.xpath # => "/a/b"
a.xpath # => "/a"
d.xpath # => ""
c = b[0] # =>
b = a[0] # => ... >
a = d.root # => ... >
d = REXML::Document.new('
relative to the most distant parent:
Returns the string xpath to the element
xpath -> string_xpath
:call-seq:
def xpath path_elements = [] cur = self path_elements << __to_xpath_helper( self ) while cur.parent cur = cur.parent path_elements << __to_xpath_helper( cur ) end return path_elements.reverse.join( "/" ) end