title: Looping through XML to create an array of hashes in Ruby
body: <p>I have the following XML</p>
  
  <pre><code>&lt;CallResult&gt;
    &lt;Success&gt;true&lt;/Success&gt;
    &lt;Result&gt;
      &lt;ZoneInfo&gt;
        &lt;Id&gt;3&lt;/Id&gt;
        &lt;Name&gt;test-room&lt;/Name&gt;
        &lt;NId&gt;sdfsdg&lt;/NId&gt;
      &lt;/ZoneInfo&gt;
      &lt;ZoneInfo&gt;
        &lt;Id&gt;16&lt;/Id&gt;
        &lt;Name&gt;Dynamic&lt;/Name&gt;
        &lt;NId&gt;sadadrwed543th&lt;/NId&gt;
      &lt;/ZoneInfo&gt;
      &lt;ZoneInfo&gt;
        &lt;Id&gt;32&lt;/Id&gt;
        &lt;Name&gt;lobby&lt;/Name&gt;
        &lt;NId&gt;ssdfrgfdfg&lt;/NId&gt;
      &lt;/ZoneInfo&gt;
      &lt;ZoneInfo&gt;
        &lt;Id&gt;33&lt;/Id&gt;
        &lt;Name&gt;conf&lt;/Name&gt;
        &lt;NId&gt;sdfsfewr232f&lt;/NId&gt;
      &lt;/ZoneInfo&gt;
    &lt;/Result&gt;
    &lt;Message&gt;Success&lt;/Message&gt;
  &lt;/CallResult&gt;
  </code></pre>
  
  <p>I am trying to parse the XML so that each different 'ZoneInfo' attributes is a hash in an array.</p>
  
  <p>E.g.</p>
  
  <p>Zones[0] = Hash[Id => 32, Name => lobby, NId => ssdfrgfdfg]</p>
  
  <p>Zones[1] = Hash[Id => 33, Name => conf, NId => sdfsfewr232f]
  etc...</p>
  
  <p>My limited XML parsing knowledge has come a croper. All I really know is how to extract a single element. E.g.</p>
  
  <pre><code>doc = REXML::Document.new(xmlData)
  doc.elements.each("CallResult/Success") do |ele|
    p ele.text;
  end
  </code></pre>
  
  <p>Could someone help with some more info on how to loop through just extracting info from each 'ZoneInfo' element?</p>
  
  <p>Thanks</p>