I'm trying to get the page title from XML Feeds.
I'm using http://feeds.gawker.com/lifehacker/full
as an example and using the below code works with other sites but for Lifehacker
it seems to ignore the closing </title>
tag and console.log shows the entire content of the xml
feed from after the opening <title>
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<title\>(.*)<\/title\>/",$str,$title);
return $title[1];
}
}
$feed = 'http://feeds.gawker.com/lifehacker/full';
$pagetitle = getTitle($feed);
Thanks