Problem with use php DOM to parse html
<p>I use DOMDocument of PHP to parse a HTML source (got via cURL). cURL work nice but When I use DOM to parse, a problem occur. See the code.</p>

<pre><code>    &lt;?php
    $url = "http://www.google.com.vn/advanced_search?hl=en";
    $ch = curl_init($url);
    $header = array();
    $header[0]  = "Accept: text/xml,application/xml,application/xhtml+xml,";
    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
    $header[]   = "Cache-Control: max-age=0";
    $header[]   = "Connection: keep-alive";
    $header[]   = "Keep-Alive: 300";
    $header[]   = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $header[]   = "Accept-Language: en-us,en;q=0.5";
    $header[]   = "Pragma: "; // browsers keep this blank.

    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; vi; rv:1.9.2.3)  Gecko/20100401 Firefox/3.6.3 FirePHP/0.5');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
    $html = curl_exec($ch); 
    /*
     * if I do:
     * echo $html;
     * exit;    // &lt;-- it work finally
     *  numbers of &lt;td&gt; tag equal to &lt;/td&gt;
     */
     $dom = new DOMDocument();
     @$dom-&gt;loadHTML($html);
     $html = $dom-&gt;saveHTML();
     echo $html; // &lt;-- output html not right syntax . number of &lt;td&gt; tag greater than &lt;/td&gt; tag.

    ?&gt;
</code></pre>

<p>Is here a programming error or DOMDocument bug?</p>
