title: How to add attribute to Nokogiri node?
body: <p>I'm trying to add an attribute to an existing Nokogiri node. What I've done is this:</p>
  
  <pre><code>node.attributes['foobar'] = Nokogiri::XML::Attr.new('foo', 'bar')
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>TypeError Exception: wrong argument type String (expected Data)
  </code></pre>
  
  <p>What is a <code>Data</code> data type, and how do I add an attribute to the Nokogiri object?</p>
  
  <p>Thanks!</p>