How does the xml generated by dom in php output to the page ;? Php $ id]; $ n & nbsp; $ _ GET [n]; contains the database connection file include (conn. php); $ domnew & nbsp; DomDocument (1.0, & nbsp; UTF-8); $ dom-& gt; how to output the xml generated by dom in formatOu php to the page
$ Id = $ _ GET ['id'];
$ N = $ _ GET ['n'];
// Contains the database connection file
Include ('Conn. php ');
$ Dom = new DomDocument ('1. 0', 'utf-8 ');
$ Dom-> formatOutput = true;
If ($ category = ""){
Exit;
};
// Create the root node
$ Element = $ dom-> createElement ('element ');
$ Dom-> appendchild ($ element );
$ Element-> setAttribute ('N', $ n );
$ Query = mysql_query ("select * from pictures order by LevelID = '$ ID '");
While ($ result = mysql_fetch_array ($ query ))
{
$ T = $ dom-> createElement ('e ');
$ T-> setAttribute ('cr ', $ result ['c']);
$ T-> setAttribute ('isnew', $ result ['isnew']);
$ T-> setAttribute ('fileurl', $ result ['fileurl']);
$ Element-> appendChild ($ t );
Print_r ($ dom-> saveXML ());
}
Echo $ dom-> saveXML ();
?>
Neither print nor echo can output dom to the page,
How can the xml generated by dom in php be output to the page? thank you.
Dom? Xml
Share:
------ Solution --------------------
Echo and print can be used, but make sure there are no other outputs.
Otherwise, the browser fails to parse because of additional content.
It is best to first release a type declaration:
Header ("Content-type: text/xml ");