title: Node.js Generate html
body: <p>I have created a JavaScript program which generates a list of data. Example output below:</p>
  
  <pre><code>output one 
  output two 
  output three 
  ...
  </code></pre>
  
  <p>I would like to be able to generate a HTML file which can be saved to disk and opened with a browser. Below is a sample of the HTML I would like to generate.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;table id="history_table"&gt;
              &lt;tr&gt;
                  &lt;td&gt;header 1&lt;/td&gt;
                  &lt;td&gt;header 2&lt;/td&gt;
                  &lt;td&gt;header 3&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                 &lt;td&gt;output one&lt;/td&gt;
              &lt;/tr&gt;
              ...
          &lt;/table&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have tried doing this:</p>
  
  <pre><code>var htmlDoc = document.createElement("HMTL");
  htmlDoc.innerhtml('&lt;head&gt;&lt;/head&gt;&lt;body&gt;...&lt;/body&gt;');
  </code></pre>
  
  <p>But this is clearly wrong since the document object does not exist.</p>
  
  <p>I think this question makes sense especially from the amount of up votes it has received. can it be reopened?</p>