title: How to convert an HTML table to plain text and save it into a variable in JavaScript
body: <p>I was checking the site and found <a href="https://stackoverflow.com/questions/5002111/javascript-how-to-strip-html-tags-from-string">JavaScript: How to strip HTML tags from string?</a> but this doesn't really explains how to take this:</p>
  
  <pre><code>&lt;tr id="element.incident.comments.additional"&gt;
  &lt;td colspan="2"&gt;
  &lt;span style=""&gt;
  &lt;table cellpadding="0" cellspacing="0" style="table-layout:fixed" width="100%"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td colspan="2"&gt;
  &lt;hr&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr style=""&gt;
  &lt;td class="tdwrap"&gt;&lt;strong&gt;2014-01-23 14:45:40 - &lt;a style="color:blue" href="sys_user.do?sysparm_view=itil&amp;amp;sysparm_query=user_name=Superhero@superhero.com"&gt;SuperHero&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="right" nowrap="true"&gt;&lt;sup&gt;Additional comments&lt;/sup&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr style=""&gt;
  &lt;td colspan="2"&gt;&lt;span style="word-wrap:break-word;"&gt;received from: SDUperhero@superhero.com&lt;br&gt;&lt;br&gt;lalalalalala
  &lt;br&gt;lotsofwords&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>and get the text inside:</p>
  
  <pre><code>&lt;tr id="element.incident.comments.additional"&gt; 
  </code></pre>
  
  <p>for further parsing.</p>
  
  <p>I tried with </p>
  
  <pre><code>function strip(html)
  {
     var tmp = document.createElement("DIV");
     tmp.innerHTML = html;
     return tmp.textContent||tmp.innerText;
  }
  
  var commentsField = document.getElementById("element.incident.comments.additional").innerHTML;
  
  
  alert(strip(commentsField));
  </code></pre>
  
  <p>but I'm not sure if this is the right way as I'm not getting anything in the alert.</p>
  
  <p>Any thoughts?</p>