title: Call to undefined method DOMDocument::getElementsByClassName()
body: <p>I am trying to fetch the alt tag from the following img tag...</p>
  
  <pre><code>&lt;div class="localImage"&gt;
  
      &lt;a href="/Electronic-Deals/b/ref=amb_link_185249707_2?ie=UTF8&amp;amp;node=4192584031&amp;amp;pf_rd_m=A1VBAL9TL5WCBF&amp;amp;pf_rd_s=center-new-12&amp;amp;pf_rd_r=07C4YQ4KZ15MZJQBT2PD&amp;amp;pf_rd_t=701&amp;amp;pf_rd_p=736512207&amp;amp;pf_rd_i=20"&gt;
  
      &lt;img src="http://g-ecx.images-amazon.com/images/G/31/rcx-events/cat-navs-electronics1._V335880105_.png" alt="Electronics" border="0" height="140" width="170"&gt;&lt;/a&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>For this I have tried the following code...</p>
  
  <pre><code>$dom = new DOMDocument();
  
  @$dom-&gt;loadHTML($html2);
  
    foreach($dom-&gt;getElementsByClassName("localImage") as $tr) {
  
  $name = '';
  
  foreach($tr-&gt;getElementsByTagName('img') as $i)
  {
  $name = $i-&gt;getAttribute('alt');
  }
  echo $name;
  </code></pre>
  
  <p>But am getting the following error...</p>
  
  <pre><code>Call to undefined method DOMDocument::getElementsByClassName()
  </code></pre>
  
  <p>Can anyone please help me where am getting it wrong...as I have tried this code pattern earlier but never faced such issue earlier.</p>