What I am trying to do is include an HTML file within a PHP system (not a problem) but that HTML file also needs to be usable on its own, for various reasons, so I need to know
A solution with only one instance of DOMDocument and without loops
$d = new DOMDocument(); $d->loadHTML(file_get_contents('/path/to/my.html')); $body = $d->getElementsByTagName('body')->item(0); echo $d->saveHTML($body);