title: How to parse XML nodes to CSV with Ruby and Nokogiri
body: <p>I have an XML file:</p>
  
  <pre><code>?xml version="1.0" encoding="iso-8859-1"?&gt;
  &lt;Offers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ssc.channeladvisor.com/files/cageneric.xsd"&gt;
    &lt;Offer&gt;
     &lt;Model&gt;&lt;![CDATA[11016001]]&gt;&lt;/Model&gt;
     &lt;Manufacturer&gt;&lt;![CDATA[Crocs, Inc.]]&gt;&lt;/Manufacturer&gt;
     &lt;ManufacturerModel&gt;&lt;![CDATA[11016-001]]&gt;&lt;/ManufacturerModel&gt;
     ...lots more nodes
     &lt;Custom6&gt;&lt;![CDATA[&lt;li&gt;Bold midsole stripe for a sporty look.&lt;/li&gt;
      &lt;li&gt;Odor-resistant, easy to clean, and quick to dry.&lt;/li&gt;
      &lt;li&gt;Ventilation ports for enhanced breathability.&lt;/li&gt;
      &lt;li&gt;Lightweight, non-marking soles.&lt;/li&gt;
      &lt;li&gt;Water-friendly and buoyant; weighs only ounces.&lt;/li&gt;
      &lt;li&gt;Fully molded Croslite&amp;trade; material for lightweight cushioning and comfort.&lt;/li&gt;
      &lt;li&gt;Heel strap swings back for snug fit, forward for wear as a clog.&lt;/li&gt;]]&gt;&lt;/Custom6&gt;
    &lt;/Offer&gt;
  ....lots lots more &lt;Offer&gt; entries
  &lt;/Offers&gt;
  </code></pre>
  
  <p>I want to parse each instance of 'Offer' into its own row in a CSV file:</p>
  
  <pre><code>require 'csv'
  require 'nokogiri'
  
  file = File.read('input.xml')
  doc = Nokogiri::XML(file)
  a = []
  csv = CSV.open('output.csv', 'wb') 
  
  doc.css('Offer').each do |node|
      a.push &lt;&lt; node.content.split
  end
  
  a.each { |a| csv &lt;&lt; a } 
  </code></pre>
  
  <p>This runs nicely except I'm splitting on whitespace rather than each element of the Offer node so every word is going into its own column in the CSV file.</p>
  
  <p>Is there a way to pick up the content of each node and how do I use the node names as headers in the CSV file?</p>