title: How can I remove duplicate XML nodes using Ruby?
body: <p>Suppose I have this structure:</p>
  
  <pre><code>&lt;one&gt;
     &lt;two&gt;
       &lt;three&gt;3&lt;/three&gt;
     &lt;/two&gt;
  
     &lt;two&gt;
       &lt;three&gt;4&lt;/three&gt;
     &lt;/two&gt;
  
     &lt;two&gt;
       &lt;three&gt;3&lt;/three&gt;
     &lt;/two&gt;
  &lt;/one&gt;
  </code></pre>
  
  <p>Is there anyway of getting to this :</p>
  
  <pre><code>&lt;one&gt;
    &lt;two&gt;
      &lt;three&gt;3&lt;/three&gt;
    &lt;/two&gt;
  
    &lt;two&gt;
      &lt;three&gt;4&lt;/three&gt;
    &lt;/two&gt;
  
  &lt;/one&gt;
  </code></pre>
  
  <p>using Ruby's libraries? I managed to get <a href="http://ssscripting.wordpress.com/2009/10/12/remove-duplicate-xml-nodes-using-nokogiri/" rel="nofollow noreferrer">this</a> using Nokogiri. From my tests, it appears to work, but maybe there's another approach, a better one.</p>