title: Parsing XML with Ruby
body: <p>I'm way new to working with XML but just had a need dropped in my lap. I have been given an usual (to me) XML format. There are colons within the tags.</p>
  
  <pre><code>&lt;THING1:things type="Container"&gt;
    &lt;PART1:Id type="Property"&gt;1234&lt;/PART1:Id&gt;
    &lt;PART1:Name type="Property"&gt;The Name&lt;/PART1:Name&gt;
  &lt;/THING1:things&gt;
  </code></pre>
  
  <p>It is a large file and there is much more to it than this but I hope this format will be familiar to someone. Does anyone know a way to approach an XML document of this sort?</p>
  
  <p>I'd rather not just write a brute-force way of parsing the text but I can't seem to make any headway with REXML or Hpricot and I suspect it is due to these unusual tags.</p>
  
  <p>my ruby code:</p>
  
  <pre><code>    require 'hpricot'
      xml = File.open( "myfile.xml" )
  
      doc = Hpricot::XML( xml )
  
     (doc/:things).each do |thg|
       [ 'Id', 'Name' ].each do |el|
         puts "#{el}: #{thg.at(el).innerHTML}"
       end
     end
  </code></pre>
  
  <p>...which is just lifted from: <a href="http://railstips.org/blog/archives/2006/12/09/parsing-xml-with-hpricot/">http://railstips.org/blog/archives/2006/12/09/parsing-xml-with-hpricot/</a></p>
  
  <p>And I figured I would be able to figure some stuff out from here but this code returns nothing. It doens't error. It just returns.</p>