title: How to use getElementById
body: <p>I want to get  the values inside tds. I can do it by getElementsByTagName but I could not manage it by using getElementById.</p>
  
  <p>The HTML might look like this:</p>
  
  <pre><code>&lt;table id="myid"&gt;
  &lt;tr&gt;
  &lt;td&gt;value1&lt;/td&gt;
  &lt;td&gt;value2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;value1&lt;/td&gt;
  &lt;td&gt;value2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>The php used to access the values is:</p>
  
  <pre><code>&lt;?PHP
  $dom = new DOMDocument();
  $dom-&gt;loadHTMLfile('http://remoteDomain/thispage.html');
  $table=$dom-&gt;getElementById('myid');
  
      foreach($table-&gt;getElementsByTagName('tr') as  $key =&gt;$tr){
         $tr-&gt;getElementsByTagName('td')-&gt;item(0)-&gt;nodeValue;
      }
  ?&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I got the error:
  <strong>Fatal error: Call to a member function getElementsByTagName() on a non-object in ...</strong></p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>Php info:  </p>
  
  <p>DOM/XML     enabled<br>
  DOM/XML API Version     20031129<br>
  libxml Version  2.7.3    </p>
  
  <p>Operating system: Windows</p>