DOMImplementation::createDocumentType
(PHP 5, PHP 7)
DOMImplementation :: createDocumentType - 创建一个空的DOMDocumentType对象
描述
public DOMDocumentType DOMImplementation::createDocumentType ([ string $qualifiedName = NULL [, string $publicId = NULL [, string $systemId = NULL ]]] )
创建一个空的DOMDocumentType对象。实体声明和符号不可用。不会发生实体引用扩展和默认属性添加。
参数
qualifiedName
要创建的文档类型的限定名称。
publicId
外部子集公共标识符。
systemId
外部子集系统标识符。
返回值
其ownerDocument设置为的新DOMDocumentType节点NULL
。
错误/异常
DOM_NAMESPACE_ERR
如果由命名空间发生错误,则引发qualifiedName
。
This method may be called statically, but will issue an E_STRICT
error.
例子
示例#1使用附加的DTD创建文档
<?php
//?Creates?an?instance?of?the?DOMImplementation?class
$imp?=?new?DOMImplementation;
//?Creates?a?DOMDocumentType?instance
$dtd?=?$imp->createDocumentType('graph',?'',?'graph.dtd');
//?Creates?a?DOMDocument?instance
$dom?=?$imp->createDocument("",?"",?$dtd);
//?Set?other?properties
$dom->encoding?=?'UTF-8';
$dom->standalone?=?false;
//?Create?an?empty?element
$element?=?$dom->createElement('graph');
//?Append?the?element
$dom->appendChild($element);
//?Retrieve?and?print?the?document
echo?$dom->saveXML();
?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE graph SYSTEM "graph.dtd">
<graph/>
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com