The created xml data cannot be displayed & lt ;? Php $ docnewDOMDocument (1.0); wewantaniceoutput $ doc-& gt; formatOutputtrue; $ root $ doc-& gt; createElement (book); $ root $ doc-& gt; appendChild ($ root); $ the xml data created cannot be displayed.
$ 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 ";
Echo $ doc-> saveXML (). "\ n ";
Echo "Saving only the title part: \ n ";
Echo $ doc-> saveXML ($ title );
?>
Echo to show only
Saving all the document: Saving only the title part:
Xml content cannot be displayed!
------ Solution --------------------
View webpage source files