时间:2021-07-01 10:21:17 帮助过:21人阅读
$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) "" This is the title
明白了,Thanks!