module ActiveSupport::XmlMini_REXML

def collapse(element, depth)

The document element to be collapsed.
element::

Actually converts an XML document element into a data structure.
def collapse(element, depth)
  hash = get_attributes(element)
  if element.has_elements?
    element.each_element { |child| merge_element!(hash, child, depth - 1) }
    merge_texts!(hash, element) unless empty_content?(element)
    hash
  else
    merge_texts!(hash, element)
  end
end