I have the following code:
<?php
$implementation = new DOMImplementation();
$document = $implementation->createDocument('http://www.w3.org/1999/xhtml', 'html', $implementation->createDocumentType('html'));
echo $document->saveHTML();
?>
which returns:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"></html>
...exactly as I wanted it to. However, when I run the following:
<?php
$implementation = new DOMImplementation();
$document = $implementation->createDocument('http://www.w3.org/1999/xhtml', 'html', $implementation->createDocumentType('html'));
$head = $document->createElement('head');
$document->appendChild($head);
echo $document->saveHTML();
?>
I get:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"></html><head></head>
...when I was trying to get:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head></head></html>
Does anyone know where I've gone wrong? It appears I might have missed something in the Manual whilst searching for a solution.
Thanks in advance for any help/tips/pointers :)