class REXML::Element

def document


Related: #root, #root_node.

d.document == d # => true

For a document, returns +self+:

REXML::Element.new.document # => nil

If the element is not part of a document, returns +nil+:

child.document == d # => true
top_element.document == d # => true
child = top_element.first
top_element = d.first
d = REXML::Document.new('')

If the element is part of a document, returns that document:

document -> document or nil
:call-seq:
def document
  rt = root
  rt.parent if rt
end