Not everyone finds the REXML API intuitive. XmlSimple is the Ruby port of the Perl XML::Simple module.

Let’s try the same web search example using XmlSimple.

require 'net/http'
require 'rubygems'
require 'xmlsimple'

url = ''
xml_data = Net::HTTP.get_response(URI.parse(url)).body

data = XmlSimple.xml_in(xml_data)

data['Result'].each do |item|
   item.sort.each do |k, v|
      if ["Title", "Url"].include? k
         print "#{v[0]}" if k=="Title"
         print " => #{v[0]}\n" if k=="Url"

XmlSimple “slurps” the XML data and converts it to a native Ruby data structure.