title: DOMDocument return empty data
body: <p>I am try to learn data scrapping from other website so I started by trying creating a small HTML file.</p>
  
  <p><strong>domhtml.php :</strong></p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;div id="mango"&gt;
              This is the mango div. It has some text and a form too.
              &lt;form&gt;
                  &lt;input type="text" name="first_name" value="Yahoo" /&gt;
                  &lt;input type="text" name="last_name" value="Bingo" /&gt;
              &lt;/form&gt;
  
              &lt;table class="inner"&gt;
                  &lt;tr&gt;&lt;td&gt;Happy&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
  
          &lt;table id="data" class="outer"&gt;
              &lt;tr&gt;&lt;td&gt;Happy1&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Happy2&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Happy3&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Happy4&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Happy5&lt;/td&gt;&lt;td&gt;Sky&lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>extract.php :</strong></p>
  
  <pre><code>&lt;?php
  
  $ch = curl_init("http://192.168.0.198/projects/domhtml.php");
  
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  
  $cl = curl_exec($ch);
  
  
  $dom = new DOMDocument();
  $dom-&gt;loadHTML($cl);
  $dom-&gt;validate();
  $title = $dom-&gt;getElementById("mango");
  
  //var_dump($title);exit;
  
  //$title = $dom-&gt;saveXML($title);
  
  echo '&lt;pre&gt;';
  print_r($title);
  
  
  ?&gt;
  </code></pre>
  
  <p>But it returns output : </p>
  
  <pre><code>DOMElement Object
  (
  )
  </code></pre>
  
  <p>why it is empty ? What is to be done other then this ? I also tried <a href="https://stackoverflow.com/questions/2477790/php-dom-not-retrieving-element">PHP Dom not retrieving element</a> solution but it return the same.</p>
  
  <p><strong>Edit :</strong></p>
  
  <p>Ok as you all guys told me I have done this :</p>
  
  <pre><code>$ch = curl_init("http://192.168.0.198/shopclues/domhtml.php");
  
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  
  $cl = curl_exec($ch);
  
  
  $dom = new DOMDocument();
  $dom-&gt;loadHTML($cl);
  $dom-&gt;validate();
  $title = $dom-&gt;getElementById("data");
  
  //var_dump($title);exit;
  
  $title = $dom-&gt;saveXML($title);
  
  echo '&lt;pre&gt;';
  print_r($title);
  </code></pre>
  
  <p>So now it is printing :</p>
  
  <pre><code>Happy1  Sky
  Happy2  Sky
  Happy3  Sky
  Happy4  Sky
  Happy5  Sky
  </code></pre>
  
  <p>I want to know the how many tr tag is there so that I can store the value of each tr in some variable. I mean how can I loop to store the value into variable ?</p>
  
  <p>Thanks in advance.</p>