Rumah >pembangunan bahagian belakang >tutorial php > DOMDocument:saveXML 返回值替空字符串
DOMDocument::saveXML 返回值为空字符串
PHP手册中的的实例:
<br /> $doc = new DOMDocument('1.0');<br /> // we want a nice output<br /> $doc->formatOutput = true;<br /> <br /> $root = $doc->createElement('book');<br /> $root = $doc->appendChild($root);<br /> <br /> $title = $doc->createElement('title');<br /> $title = $root->appendChild($title);<br /> <br /> $text = $doc->createTextNode('This is the title');<br /> $text = $title->appendChild($text);<br /> <br /> <br /> echo "Saving all the document:\n";<br /> <br /> $xmlContent = $doc->saveXML();<br /> <br /> var_dump($xmlContent);<br />