加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

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

发布时间:2020-05-25 09:07:57 所属栏目:PHP 来源:互联网
导读:我使用以下方法在 PHP中导出了一个xml文件: $xmldoc = new DOMDocument(); $xmldoc-formatOutput = true;$xmldoc-encoding=Shift_JIS;// create root nodes$root = $xmldoc-createElement(TableData);$xmldoc-a

我使用以下方法在 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.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读