I\'m manipulating a short HTML snippet with XPath; when I output the changed snippet back with $doc->saveHTML(), DOCTYPE
gets added, and HTML / BODY
tl;dr
requires: PHP 5.4.0
and Libxml 2.6.0
test$doc->loadHTML("
explanation
http://php.net/manual/en/domdocument.loadhtml.php "Since PHP 5.4.0 and Libxml 2.6.0, you may also use the options parameter to specify additional Libxml parameters."
LIBXML_HTML_NOIMPLIED
Sets HTML_PARSE_NOIMPLIED flag, which turns off the automatic adding of implied html/body... elements.
LIBXML_HTML_NODEFDTD
Sets HTML_PARSE_NODEFDTD flag, which prevents a default doctype being added when one is not found.