$html = file_get_contents("$url"); $html = tidy_repair_string($html); //echo "$html"; $doc = new DomDocument(); $doc->loadHTML($html); $xpath = new DomXPath($doc); $query = $xpath->query('//title'); foreach ($query as $value) { $title = $value->nodeValue; }