title: Scrape links from HTML
body: <p>I have been always using <code>preg_match</code> to scrape URLs from HTML files but I wanted to extract only URLs that have <code>.mp3</code> as their extension. I was told to try DOM and I have been trying to fix a code but it doesn't work. I get a blank page whatever I do. </p>
  
  <p>What am I doing wrong? </p>
  
  <pre><code>&lt;?php
      $url = 'http://www.mp3olimp.net/miley-cyrus-when-i-look-at-you/';
      $html = @file_get_html($url);
      $dom = new DOMDocument();
      $doc-&gt;loadHTML($html);
      $xpath = new DOMXPath($doc); 
      $links = $xpath-&gt;query('//a[ends-with(@href, ".mp3")]/@href');
  
      echo $links;
  ?&gt;
  </code></pre>