This example describes the solution to the header of PHP output XML. Share to everyone for your reference. The specific methods are as follows:
Problem Description:
The most recent XML output that we used to input with Echo would prompt Error:object # has no method ' load ' error, and then the header () Output XML header file was resolved, as recorded below.
Workaround:
Because the XML long and TXT file is too similar, so cause i sum txt confused.
Now take a look at the following code:
Copy Code code 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
This is a piece of code, anyway. XML cannot be validated by XML.
Prompt error Error:object # has no method ' load '
The last time I checked, it was just like a file in 1.xml.
The specific code is as follows
Copy Code 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>
It would be nice to add a header. It's been a couple of hours.
The specific code is as follows
Copy Code code 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
I hope this article will help you with your PHP program design.