title: Extract part of the code and parse HTML in bash
body: <p>I have external HTML site and I need to extract data from the table on that site. However source of the HTML website has wrong formatting except the table in the code, so I can not use </p>
  
  <pre><code>xmllint --html --xpath &lt;xpath&gt; &lt;file&gt;
  </code></pre>
  
  <p>because it does not work properly, when HTML formatting on the site is broken.</p>
  
  <p>My idea was to use curl and delete code above and below the table. When table is extracted, code is clean and it fits to <strong>xmllint</strong> tool (I can use xpath then). However delete everything above the match is challenging for shell as you can see here: <a href="https://unix.stackexchange.com/questions/29906/delete-range-of-lines-above-pattern-with-sed-or-awk">Sed doesn't backtrack: once it's processed a line, it's done.</a>
  Is there a way how to extract only the code of the table from the HTML site in bash? Suposse, code has this structure.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;Lorem ipsum ....&lt;/p&gt;
    &lt;table class="my-table"&gt;
      &lt;tr&gt;
        &lt;th&gt;Company&lt;/th&gt;
        &lt;th&gt;Contact&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;p&gt;... dolor.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And I need output like this to parse data properly:</p>
  
  <pre><code>  &lt;table class="my-table"&gt;
      &lt;tr&gt;
        &lt;th&gt;Company&lt;/th&gt;
        &lt;th&gt;Contact&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>Please, do not give me minus because of trying to use bash. </p>