当前位置:Gxlcms > PHP教程 > DOMDocument:saveXML返回值替空字符串

DOMDocument:saveXML返回值替空字符串

时间:2021-07-01 10:21:17 帮助过:7人阅读

DOMDocument::saveXML 返回值为空字符串
PHP手册中的的实例:

$doc = new DOMDocument('1.0');
// we want a nice output
$doc->formatOutput = true;

$root = $doc->createElement('book');
$root = $doc->appendChild($root);

$title = $doc->createElement('title');
$title = $root->appendChild($title);

$text = $doc->createTextNode('This is the title');
$text = $title->appendChild($text);


echo "Saving all the document:\n";

$xmlContent = $doc->saveXML();

var_dump($xmlContent);


打印出的结果是:
Saving all the document: string(72) " "

为什么没有打印出完整的XML?请各位前辈指点,Thanks! PHP saveXML

分享到:


------解决方案--------------------
请在文本方式下查看
Saving all the document:
string(72) "

This is the title

"

人气教程排行