def src
<
EOS
end
def parse_children(results, parent)
return unless parent
parent.elements.inject(results){|re, e|
re << e
parse_children(re, e)
re
}
end
require 'rexml/document'
doc = REXML::Document.new src
root = doc.elements[1]
results = []
results << root
parse_children(results, doc.elements[1]).each{ |n|
puts "element_name=>#{n.name}"
n.attributes.keys.each{ |att| puts " attribute_name=>#{att}" }
}
element_name=>Hoge
attribute_name=>y
attribute_name=>z
element_name=>Fuga
attribute_name=>a
attribute_name=>b
attribute_name=>c
element_name=>Foooo
attribute_name=>d
element_name=>Fuga
attribute_name=>a
attribute_name=>b
attribute_name=>c