module ActiveSupport::XmlMini_JDOM

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)
  child_nodes = element.child_nodes
  if child_nodes.length > 0
    (0...child_nodes.length).each do |i|
      child = child_nodes.item(i)
      merge_element!(hash, child, depth - 1) unless child.node_type == Node.TEXT_NODE
    end
    merge_texts!(hash, element) unless empty_content?(element)
    hash
  else
    merge_texts!(hash, element)
  end
end