code: function createDocument(root, namespace) {
      if (!root)
        return document.implementation.createHTMLDocument();
      else
        return document.implementation.createDocument(
          namespace || null,
          root,
          null
        );
    }
docs: Creating an HTML or XML document