how to parse html table with php
<p>I would really appreciate if somebody could give me a hint on how to parse this kind of tables and show results in a specific order.</p>

<p>So the piece of html I have is </p>

<pre><code>&lt;table name="maintable" cellspacing="2" cellpadding="3" border="0" id="grid_block" width="100%" class="csm"&gt;
&lt;tr class="shade" style="font-weight: bold"&gt;
    &lt;td width="30%"&gt;Name&lt;/td&gt;
    &lt;td width="70%"&gt;NameOne&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="shade" style="font-weight: bold"&gt;
        &lt;td&gt;Date&lt;/td&gt;
        &lt;td&gt;2012-09-30&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;table name="maintable" cellspacing=2 cellpadding=3 border=0 id="grid_block" width="100%" class="csm"&gt;
        &lt;tr&gt;
            &lt;td colspan="12" align="center" bgcolor="#90ee90"&gt;&lt;b&gt;In Stock&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr onmouseover="this.className = 'rowselected';" onmouseout="this.className = 'shade';"&gt;
            &lt;td class="greenshade"&gt;&lt;b&gt;Color/Size&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;OO&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;2&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;4&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;6&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;8&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;10&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;12&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;14&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;16&lt;/b&gt;&lt;/td&gt;
            &lt;td align="center" class="greenshade"&gt;&lt;b&gt;18&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr onmouseover="this.className = 'rowselected';" onmouseout="this.className = 'shade';"&gt;
                &lt;td width='30%' &gt;&lt;b&gt;black&lt;/b&gt;&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr onmouseover="this.className = 'rowselected';" onmouseout="this.className = 'shade';"&gt;
                &lt;td width='30%' &gt;&lt;b&gt;nude&lt;/b&gt;&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
                &lt;td align="Center"&gt;-&lt;/td&gt;
        &lt;/tr&gt;
</code></pre>

<p>and the problem is that I need to parse this table and output it in this form: </p>

<p>;nameOne;black;OO;-;</p>

<p>;nameOne;black;0;-;</p>

<p>;nameOne;black;2;-;</p>

<p>etc.</p>

<p>so basically - name(from the first table), color, size, quantity; for every color and size.</p>

<p>I have been trying to accomplish this for the last two days and no luck so far, so I would appreciate any help!
Thank you!</p>
