我使用以下方法在
PHP中导出了一个xml文件:
$xmldoc = new DOMDocument(); $xmldoc->formatOutput = true; $xmldoc->encoding="Shift_JIS"; // create root nodes $root = $xmldoc->createElement("TableData"); $xmldoc->appendChild( $root ); $xmldoc->save($filename);
结果:
<?xml version="1.0" encoding="Shift_JIS"?> <TableData> </TableData>
现在,我想添加行<!DOCTYPE TableDef SYSTEM“TableData.dtd”>喜欢:
<?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE TableDef SYSTEM "TableData.dtd"> <TableData> </TableData>
如何在导出的xml中添加DOCTYPE?谢谢.
见
PHP DOM: change doctype of existing DOMDocument
原文链接:https://www.f2er.com/php/444946.htmlWhen creating a DOMDocument with 07001,you can specify a doctype as the third argument in the constructor. This doctype then gets “tied” to the document and you can retrieve it later with $document->doctype.