I'm curious if there is a way to create DocType nodes via W3C DOM? The spec explicitly states that they are readonly and cannot be edited, but are they able to be created?
http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-412266927
The Document interface doesn't seem to have any create method for it:
Perhaps the broader question is: Can an entirely new HTML Document be built programmatically via DOM? I know about document.createDocumentFragment() but I mean the equivalent of a root HTML document with specific doctype, etc.
Update: it looks like recent Gecko and WebKit implement DOMImplementation.createDocument and DOMImplementation.createDocumentType but not IE8 or before (haven't checked IE9). So unfortunately I'm still stuck there.
I am also a bit unsure what I can do with this new Document instance once I have it. All of the current DOM methods hang off the global document object, so there doesn't seem to be a way to swap it with a new one.