title: Using Nokogiri with XML files in Ruby
body: <p>I have this XML:</p>
  
  <pre><code>&lt;Experiment&gt;
  &lt;mzData version="1.05" accessionNumber="1635"&gt;
  &lt;description&gt;
  &lt;admin&gt;
  &lt;sampleName&gt;Fas-induced and control Jurkat T-lymphocytes&lt;/sampleName&gt; 
  &lt;sampleDescription&gt;
  &lt;cvParam cvLabel="MeSH" accession="D017209" name="apoptosis" /&gt; 
  &lt;cvParam cvLabel="UNITY" accession="D2135" name="Jurkat cells" /&gt; 
  &lt;cvParam cvLabel="MeSH" accession="D019014" name="Antigens, CD95" /&gt; 
  &lt;/sampleDescription&gt;
  &lt;/admin&gt;
  &lt;/description&gt;
  &lt;/mzData&gt;
  &lt;/Experiment&gt;
  &lt;/ExperimentCollection&gt;
  </code></pre>
  
  <p>I also have the following code:</p>
  
  <pre><code>require 'rubygems'
  require 'nokogiri'
  
  doc = Nokogiri::XML(File.open("my.xml"))
  
  sampleName = doc.xpath( "/ExperimentCollection/Experiment/mzData/description/admin/sampleName" ).text
  sampleDescription = doc.xpath( "/ExperimentCollection/Experiment/mzData/description/admin/sampleDescription/MeSH/@accession" ).text
  puts sampleName + " " + sampleDescription
  
  foo = sampleName + " " + sampleDescription 
  f = File.new("my.txt","w")
  f.write(foo) 
  f.close()
  </code></pre>
  
  <p>The code grabs the <code>sampleName</code> just fine, but not the <code>accession</code> letters/numbers. I only want to grab all the letters/numbers after <code>MeSH</code> -> <code>accession</code> (<code>D017209</code> and <code>D019014</code>). What do I have to change in the <code>doc.xpath</code> command to make this work?</p>