public function writeHTML($path = null)
{
if ($path == null) {
echo $this->document->saveHTML();
} else {
try {
set_error_handler(array('\\QueryPath\\ParseException', 'initializeFromError'));
$this->document->saveHTMLFile($path);
} catch (Exception $e) {
restore_error_handler();
throw $e;
}
restore_error_handler();
}
return $this;
}