title: NoMethodError using Nokogiri
body: <p>I'm creating an import script using Nokogiri to parse an XML file and then looping through the nodes creating new "Products" in my database. Everything works ok except for the pesky price field (which is a float).</p>
  
  <pre><code>Product.create(:name =&gt; node.xpath("./text/name/text()"), 
                 :description =&gt; node.xpath("./text/desc/text()"),
                 :brand =&gt; node.xpath("./brand/brandName/text()"),
                 :merchant =&gt; node.xpath("../@name"),
           &gt;&gt; (A) #:price =&gt; 1.99))
           &gt;&gt; (B) #:price =&gt; node.xpath("./price/buynow/text()"))
           &gt;&gt; (C) #:price =&gt; node.xpath("./price/buynow/text()").to_f))
  </code></pre>
  
  <p>The XML node in question looks like this...</p>
  
  <pre><code>&lt;buynow&gt;6.99&lt;/buynow&gt;  
  </code></pre>
  
  <p>When I try line (A) to test it works fine, but obviously undesired.</p>
  
  <p>When I try line (B) or (C) to attempt to get the value from the node, my page hangs, WEBrick needs to be restarted (no errors in terminal) and the following error appears within the log:</p>
  
  <pre><code>NoMethodError (undefined method `to_f' for [#&lt;Nokogiri::XML::Text:0x81f5220c "6.99"&gt;]:Nokogiri::XML::NodeSet):
  </code></pre>
  
  <p><strong>Note:</strong> the same error appears even if I don't explicitly invoke the to_f method </p>
  
  <p>I'm guessing I need to convert the node value to a float somehow, but the obvious way is causing the error!</p>
  
  <p>Can someone shed some light on this one?</p>