title: Export entire html <table> to a text document using Watir
body: <p>Basically all I would like to do is export a whole html table to a .txt file (notepad document).</p>
  
  <p>So far I have learnt how to instruct the browser to find the html page with the table.</p>
  
  <pre><code>require 'rubygems' 
  require 'hpricot' 
  require "watir-webdriver" 
  url = "http://www.example.com"
  browser = Watir::Browser.new 
  browser.goto url
  </code></pre>
  
  <p>After running the above in cmd I can now see the html table in the browser.</p>
  
  <p>This is where I am stuck. How do I use Watir to </p>
  
  <ol>
  <li>Find the  tag</li>
  <li>collect everything (i.e. the html ,  and the text) which is within  and .</li>
  <li>Extract those results to a .txt file (notepad document) and save it in a specific folder.</li>
  </ol>
  
  <p>FYI the html table looks like this...</p>
  
  <pre><code>&lt;table border="1" cellpadding="2"&gt;
  &lt;tr&gt;
  &lt;th&gt; Address &lt;/th&gt;
  &lt;th&gt; Council tax band &lt;/th&gt;
  &lt;th&gt; Annual council tax &lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; 2, STONELEIGH AVENUE, COVENTRY, CV5 6BZ &lt;/td&gt;
  &lt;td align="center"&gt; F &lt;/td&gt;
  &lt;td align="center"&gt; &amp;pound;2125 &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>....... The above row is repeated many time ......</p>
  
  <pre><code>&lt;/table&gt; 
  </code></pre>
  
  <p>Then the table is closed.</p>
  
  <p>So to re-cap my situation. I can use Watir to navigate the browser to the page containing the html table but my problem is that I am unsure of how to extract the results (everything within the  tag - including the html) to a .txt file and then save that .txt file onto my computer.</p>
  
  <p>I would prefer to take smaller steps with using Watir. I am knew to it therefore I would just like to learn how to extract the table and save everything that I have extracted into a .txt file. I have seen a couple of examples online using hpricot. However most of the examples seem to miss off code detailing how the array (if that is the correct approach) is outputted into a .txt file.</p>
  
  <p>Could you help by demonstrating how to write a simple piece of code which will extract the html table ( and everything, including the ,  and everything in between) to a .txt notepad file?</p>
  
  <p>Many thanks for your time.</p>