public function setTitle($value, $position = null) { $doc = new XMLDocument(); $doc->loadHTML("<title>{$value}</title>"); $node = $this->importNode($doc->xpath('//title')->item(0), true); return $this->insertNodeIntoHead($node, $position); }