title: How to save my changes in XML file with Nokogiri
body: <p>I have the following simple XML file.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;user-mapping&gt;
  
  &lt;/user-mapping&gt;
  </code></pre>
  
  <p>I want to add content to the user mapping using Nokogiri.</p>
  
  <p>This is my code:</p>
  
  <pre><code>f = File.open("exam.xml")
  doc = Nokogiri::XML(f)
  puts doc.to_s
  map = doc.at_css "user-mapping"
  map.content = "Gholam"
  puts map.to_s
  doc.to_xml
  f.close
  </code></pre>
  
  <p>The output of the <code>puts</code> are:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;user-mapping&gt;
  
  &lt;/user-mapping&gt;
  &lt;user-mapping&gt;Gholam&lt;/user-mapping&gt;
  </code></pre>
  
  <p>But when the code ends, nothing has been change in the actual XML file.
  Can anyone explain to me how to save my changes in the XML file?</p>