【问题标题】:How to make DOMDocument write standalone=yes in PHP?如何使 DOMDocument 在 PHP 中编写独立 = 是?
【发布时间】:2010-10-01 22:17:29
【问题描述】:

我正在使用 PHP5 创建 XML 文件。我有这样的代码:

$doc = new DOMDocument();
...
$xml_content = $doc->saveXML();

问题是创建的 XML 代码以这样的根节点开始:

<?xml version="1.0"?>

但我希望它是这样的:

<?xml version="1.0" standalone="yes" ?>

我想我需要调用 $doc 上的某个函数,但我不知道是哪一个?

【问题讨论】:

    标签: php xml domdocument


    【解决方案1】:

    你想设置

    $doc->xmlStandalone = true;
    

    它不是类的函数,它是一个属性,因此在文档中很难找到。你可以阅读它here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 2014-06-30
      • 1970-01-01
      • 2012-01-22
      相关资源
      最近更新 更多