$this->startDocument($this->_xmlVersion, $this->_charSet);
XML解析失败
XML解析失败:语法错误(行:1,字符:1)
Error: XML declaration not at beginning of document Specificat`enter code here`ion: http://www.w3.org/TR/REC-xml/ 1: <?xml version="1.0" encoding="UTF-8"?> Empty space before <?
如何删除它?
答案 0 :(得分:1)
你在用什么?您的代码看起来不像XMLWriter
:
$x = new XMLWriter();
$x->openMemory();
$x->startDocument('1.0','UTF-8');
var_dump($x->outputMemory());
这没有额外的空间。
答案 1 :(得分:1)
我可能由?>
引起 - 查看你的库,钩子等等并删除它。
答案 2 :(得分:0)
尝试ob_clean()
,但首先要确保输出buffering(ob_start())
已启用。
答案 3 :(得分:0)
使用ob_clean(),就我而言,它可以解决我的问题。
header("Content-type: text/xml");
$xml = new \XmlWriter();
$xml->openMemory();
$xml->startDocument($this->version, $this->encoding);
ob_clean();