Php output xml header Solution

Source: Internet
Author: User

Php output xml header Solution

Problem description:

Recently, when we made an xml output, we found that the xml document we directly used echo to input will prompt Error: Object # has no method 'load' Error, and then changed header () the output xml header file is fixed. Record it below.

Solution:

Because the xml length is too similar to that of the txt file, it causes me to confuse the total txt files.

Now let's take a look at the following code:

The Code is as follows:

Echo '<? Xml version = "1.0" encoding = "UTF-8"?>
<Sitemap>
<Loc> http://www.jb51.net/</loc>
<Lastmod> 2013-01-22T11: 00: 18 + 08: 00 </lastmod>
</Sitemap>
';
Exit;


Such a piece of code does not allow xml verification.
Error message: Error: Object # has no method 'load'
The last half-day query is the same as the files directly placed in 1.xml.
The Code is as follows:

Copy the Code as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Sitemap>
<Loc> http://www.jb51.net/</loc>
<Lastmod> 2013-01-22T11: 00: 18 + 08: 00 </lastmod>
</Sitemap>


Just add a header. I 've been tossing for several hours .....
The Code is as follows:

The Code is as follows:

<? Php
Header ("Content-type: text/xml ");
Echo '<? Xml version = "1.0" encoding = "UTF-8"?>
<Sitemap>
<Loc> http://www.jb51.net/</loc>
<Lastmod> 2013-01-22T11: 00: 18 + 08: 00 </lastmod>
</Sitemap>
';
Exit;

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.