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;