Suppresses any parsing errors from invalid HTML or missing elements:
<? $doc = new DOMDocument(); @$doc->loadHTML(@file_get_contents("http://www.washingtonpost.com")); // find the title $titlelist = $doc->getElementsByTagName("title"); if($titlelist->length > 0){ echo $titlelist->item(0)->nodeValue; }
source share