title: How to convert HTML table to array with golang
body: <p>I'm having a problem trying to convert an HTML table into a Golang array. I've tried to achieve it using x/net/html and goquery, without any success on both of them.</p>
  <p>Let's say we have this HTML table:</p>
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;table&gt;
        &lt;tr&gt;
          &lt;td&gt;Row 1, Content 1&lt;/td&gt;
          &lt;td&gt;Row 1, Content 2&lt;/td&gt;
          &lt;td&gt;Row 1, Content 3&lt;/td&gt;
          &lt;td&gt;Row 1, Content 4&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Row 2, Content 1&lt;/td&gt;
          &lt;td&gt;Row 2, Content 2&lt;/td&gt;
          &lt;td&gt;Row 2, Content 3&lt;/td&gt;
          &lt;td&gt;Row 2, Content 4&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>And I'd like to end up with this array:</p>
  <pre><code>------------------------------------
  |Row 1, Content 1| Row 1, Content 2|
  ------------------------------------
  |Row 2, Content 1| Row 2, Content 2|
  ------------------------------------
  </code></pre>
  <p>As you guy can see, I'm just ignoring Contents 3 and 4.</p>
  <p>My extraction code:</p>
  <pre><code>func extractValue(content []byte) {
    doc, _ := goquery.NewDocumentFromReader(bytes.NewReader(content))
  
    doc.Find(&quot;table tr td&quot;).Each(func(i int, td *goquery.Selection) {
      // ...
    })
  }
  </code></pre>
  <p>I've tried to add a controller number which would be responsible for ignoring the <code>&lt;td&gt;</code> that I don't want to convert and calling</p>
  <pre><code>td.NextAll()
  </code></pre>
  <p>but with no luck. Do you guys have any idea of what should I do to accomplish it?</p>
  <p>Thanks.</p>