title: Extract text array from HTML in JavaScript
body: <p>We are doing dynamic translation of HTML type documents using translator service API (e.g., Azure). For that we need to strip the Markup and extract only the text part, because the APIs have character limit and we don't want to send useless markup characters to the API.</p>
  <p>So if there is a HTML like below:</p>
  <pre><code>&lt;div&gt;
  &lt;div&gt;
      &lt;p&gt;Hello&lt;/p&gt;
      &lt;div&gt;
          &lt;p&gt;There&lt;/p&gt;
      &lt;/div&gt;
      &lt;div&gt;World&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;div&gt;We are back&lt;/div&gt;
      &lt;div&gt;
          &lt;p&gt;Members&lt;/p&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Age&lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Satt&lt;/td&gt;
                  &lt;td&gt;10&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Matt&lt;/td&gt;
                  &lt;td&gt;20&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  We want the text values in an array, like:
  <pre><code>[&quot;Hello&quot;, &quot;There&quot;, &quot;World&quot;, &quot;We are back&quot;, &quot;Members&quot;, &quot;Name&quot;, &quot;Age&quot;, &quot;Satt&quot;, &quot;10&quot;, &quot;Matt&quot;, &quot;20&quot;]
  </code></pre>
  <p>What is the best approach to do this? Should I use Regular expressions to parse and extract the HTML or should I use some kind of recursive algorithm to get the texts.</p>
  <p>Any help is appreciated, Thanks.</p>