Notes: * Use `Enumerable#map` instead of `Enumerable#each` + `Array#<<`. * Use [Kernel#Hash][1] to build a hash from its pairs. I prefer a more OOP approach so I'd use [Enumerable#mash][2] from Facets. * Use `nokogiri_node.text`. * You can (and should) unpack values in block arguments. I'd write: require 'nokogiri' require 'facets' def get_training_queue(xml_data) xml_data.xpath("//row").map do |skill_in_queue| skill_in_queue.attributes.mash do |name, attribute| [name.to_sym, attribute.text] end end end All those `each` and in-place updates show that you think in imperative terms instead of functional, check [this wiki page][3]. [1]: http://ruby-doc.org/core-2.0/Kernel.html#method-i-Hash [2]: http://rdoc.info/github/rubyworks/facets/master/Enumerable#graph-instance_method [3]: http://code.google.com/p/tokland/wiki/RubyFunctionalProgramming