- XML DOM 基礎
- XML DOM - 首頁
- XML DOM - 概述
- XML DOM - 模型
- XML DOM - 節點
- XML DOM - 節點樹
- XML DOM - 方法
- XML DOM - 載入
- XML DOM - 遍歷
- XML DOM - 導航
- XML DOM - 訪問
- XML DOM 操作
- XML DOM - 獲取節點
- XML DOM - 設定節點
- XML DOM - 建立節點
- XML DOM - 新增節點
- XML DOM - 替換節點
- XML DOM - 刪除節點
- XML DOM - 克隆節點
- XML DOM 物件
- DOM - Node 物件
- DOM - NodeList 物件
- DOM - NamedNodeMap 物件
- DOM - DOMImplementation
- DOM - DocumentType 物件
- DOM - ProcessingInstruction
- DOM - Entity 物件
- DOM - EntityReference 物件
- DOM - Notation 物件
- DOM - Element 物件
- DOM - Attribute 物件
- DOM - CDATASection 物件
- DOM - Comment 物件
- DOM - XMLHttpRequest 物件
- DOM - DOMException 物件
- XML DOM 有用資源
- XML DOM - 快速指南
- XML DOM - 有用資源
- XML DOM - 討論
DOM - DOMImplementation 物件方法 - createdocument
createDocumentType() 方法用於建立一個空的 DocumentType 節點。實體宣告和符號不可用。
語法
以下是 createDocument() 方法的語法。
Document doc = document.implementation.createDocumentType(qualifiedName, publicId, systemId);
qualifiedName 是要建立的文件型別的限定名稱。
publicId 是外部子集公共識別符號。
systemId 外部子集系統識別符號。
此方法返回一個新的 DocumentType 節點,其中 Node.ownerDocument 設定為 null。
示例
以下示例演示了 createDocumentType() 方法的使用:
<!DOCTYPE html>
<html>
<body>
<script>
var dt = document.implementation.createDocumentType('svg:svg',
'-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
var d = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', dt);
document.write(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN
</script>
</body>
</html>
執行
將此檔案儲存為伺服器路徑上的 domimplementation_createdocumenttype.htm(此檔案和 node.xml 應位於伺服器上的同一路徑)。我們將獲得如下所示的輸出:
-//W3C//DTD SVG 1.1//EN
dom_domimplementation_object.htm
廣告