title: How do I get the link element in a html page with PHP
body: <p>First, I know that I can get the HTML of a webpage with:</p>
  
  <pre><code>file_get_contents($url);
  </code></pre>
  
  <p>What I am trying to do is get a specific link element in the page (found in the head).</p>
  
  <p>e.g:</p>
  
  <pre><code>&lt;link type="text/plain" rel="service" href="/service.txt" /&gt; (the element could close with just &gt;)
  </code></pre>
  
  <p>My question is: How can I get that specific element with the "rel" attribute equal to "service" so I can get the href?</p>
  
  <p>My second question is: Should I also get the "base" element? Does it apply to the "link" element? I am trying to follow the standard.</p>
  
  <p>Also, the html might have errors. I don't have control on how my users code there stuff.</p>