DOMDocument::saveXML 返回值为空字符串

WBOY
Release: 2016-06-23 14:26:29
Original
1354 people have browsed it

PHP 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);
Copy after login


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

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


回复讨论(解决方案)

请在文本方式下查看

Saving all the document:string(72) "<?xml version="1.0"?><book>  <title>This is the title</title></book>"
Copy after login

明白了,Thanks!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template