DOMDocument: example of an empty string returned by saveXML in the PHP Manual: & nbsp; $ doc & nbsp ;=& nbsp; new & nbsp; DOMDocument ('1. 0 '); // & nbsp; we & nbsp; want & n DOMDocument: saveXML returns an empty string
Examples in the PHP manual:
$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);
The output is as follows:
Saving all the document: string (72 )""
Why didn't the complete XML be printed? Thank you for your advice. Thanks! PHP saveXML shared to: format... 'data-pics = ''>
------ Solution --------------------
View in text mode
Saving all the document:
string(72) "
This is the title
"