title: (PHP5) Extracting a title tag and RSS feed address from HTML using PHP DOM or Regex
body: <p>I'd like to get the title tag and RSS feed address (if there is one) from a given URL, but the method(s) I've used so far just aren't working at all. I've managed to get the title tag by using preg_match and a regular expression, but I can't seem to get anywhere with getting the RSS feed address.</p>
  
  <p><em>($webContent holds the HTML of the website)</em></p>
  
  <p>I've copied my code below for reference...</p>
  
  <p>`    // Get the title tag
      preg_match('@(.*)@i',$webContent,$titleTagArray);</p>
  
  <pre><code>// If the title tag has been found, assign it to a variable
  if($titleTagArray &amp;&amp; $titleTagArray[3])
   $webTitle = $titleTagArray[3];
  
  // Get the RSS or Atom feed address
  preg_match('@&lt;link(.*)rel="alternate"(.*)href="(.*)"(.*)type="application/rss+xml"\s/&gt;@i',$webContent,$feedAddrArray);
  
  // If the feed address has been found, assign it to a variable
  if($feedAddrArray &amp;&amp; $feedAddrArray[2])
   $webFeedAddr = $feedAddrArray[2];`
  </code></pre>
  
  <p>I've been reading on here that using a regular expression isn't the best way to do this? Hopefully someone can give me a hand with this :-)</p>
  
  <p>Thanks.</p>