title: Why the original element got changed when I modify the copy created by .dup method? Ruby and REXML
body: <p>I just tested the following steps in irb and got something odd:</p>
  
  <pre><code>require 'rubygems'
  require 'rexml/document'  
  include REXML
  
  e1=Element.new("E1")
  e2=Element.new("E2")
  e1.add_element(e2)
  
  e1Dup=e1.dup
  puts e1
  puts e1Dup
  
  e1.delete_element(e1.elements[1])
  puts e1
  puts e1Dup
  </code></pre>
  
  <p>I only want changes on e1, however, the result shows both element got changed. How could this happen? The result is below:</p>
  
  <pre><code>&lt;E1&gt;&lt;E2/&gt;&lt;/E1&gt;
  &lt;E1&gt;&lt;E2/&gt;&lt;/E1&gt;
  &lt;E1/&gt;
  &lt;E1/&gt;
  </code></pre>