How to output xml generated by dom in php to the page-php Tutorial

Source: Internet
Author: User
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 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.