How can I echo XML in php? what is the problem?

Source: Internet
Author: User
Why can't php echo XML? & Lt ;? Phprequire_once (& quot; conn. php & quot;); header (& quot; Content-type: textxml & quot;); $ querySELECT * FROMtestorderbynodesc; $ resultmysql_query (why can't php echo XML with $ qu, what's the problem?
Require_once ("conn. php ");
Header ("Content-type: text/xml ");
$ Query = 'select * FROM test order by no desc ';
$ Result = mysql_query ($ query );
Echo" ";
While ($ row = mysql_fetch_assoc ($ result )){
Echo" ". $ Row-> no ." ";
Echo" ". $ Row-> ch ." ";
Echo" ". $ Row-> f ." ";
}
Echo" ";
Mysql_close ();
?>

Conn. php and database are okay. The file format is UTF-8.

Prompt in the browser:
The XML page cannot be displayed.
You cannot view XML input using a style sheet. Correct the error and click refresh or try again later.


--------------------------------------------

The top-level of the document is invalid. An error occurred while processing the resource 'http: // localhost/getXML. php. Row 1st, Location: 1

?

^


------ Solution --------------------
Mysql_fetch_assoc or mysql_fetch_object
The reason why the XML page cannot be displayed is that you disable the error message and use the IE browser.
------ Solution --------------------
The first one shown above is?
You have to check whether there are any mistakes in your page code.
However, xml is really annoying. I have tried to output xml, but some of them are normal and some are abnormal in some browsers ..

------ Solution --------------------
Could you change to firefox?
------ Solution --------------------
Discussion

I did not go down to Firefox.
Can the code be correctly displayed in your browser?

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.