title: Best way to parse an HTML table into a CSV
body: <p>I've got to grab some product data off an existing website to put into a database. The data is all in HTML table format, the model numbers are unique, but each product can have any number of different attributes (so the tables I need to parse all have different columns and headings).</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Model No.&lt;/td&gt;
  &lt;td&gt;Weight&lt;/td&gt;
  &lt;td&gt;Colour&lt;/td&gt;
  &lt;td&gt;Etc..&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;8572&lt;/td&gt;
  &lt;td&gt;12 Kg&lt;/td&gt;
  &lt;td&gt;Red&lt;/td&gt;
  &lt;td&gt;Blah..&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;7463&lt;/td&gt;
  &lt;td&gt;7 Kg&lt;/td&gt;
  &lt;td&gt;Blue&lt;/td&gt;
  &lt;td&gt;Blah..&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;8332&lt;/td&gt;
  &lt;td&gt;42 Kg&lt;/td&gt;
  &lt;td&gt;Yellow&lt;/td&gt;
  &lt;td&gt;Blah..&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>This is the CSV output format I'm looking for:</p>
  
  <pre><code>Model-No,Attribute-Name,Attribute-Value
  8572,"Weight","12 Kg"
  8572,"Colour","Red"
  8572,"Etc","Blah.."
  7463,"Weight","7 Kg"
  7463,"Colour","Blue"
  7463,"Etc","Blah.."
  8332,"Weight","42 Kg"
  8332,"Colour","Yellow"
  8332,"Etc","Blah.."
  </code></pre>
  
  <p>As the tables all appear to be valid xhtml I'll probably load each one into an XmlDocument, but does anyone have any suggestions for a better way of accomplishing this? Thanks.</p>