php – 如何在export xml中添加DOCTYPE?

前端之家收集整理的这篇文章主要介绍了php – 如何在export xml中添加DOCTYPE?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用以下方法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

When 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.

原文链接:https://www.f2er.com/php/444946.html

猜你在找的PHP相关文章