Php: php xmlheader. Php output xml must be the header of the solution, phpxmlheader this article examples of php output xml must be the header of the solution. Share it with you for your reference. The specific method is as follows: Problem description: php outputs a required header for xml, phpxmlheader
The example in this article describes the solutions for php to output xml headers. Share it with you for your reference. The specific method is as follows:
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"?>
Http://www.bkjia.com/</loc>
2013-01-22T11: 00: 18 + 08: 00
';
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:
The code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
Http://www.bkjia.com/</loc>
2013-01-22T11: 00: 18 + 08: 00
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"?>
Http://www.bkjia.com/</loc>
2013-01-22T11: 00: 18 + 08: 00
';
Exit;
I hope this article will help you with php programming.
How can I enter the xml mode when the php output xml type is text/xml?
/*
Write xml files
*/
Mysql_connect ('localhost', 'root ','');
Mysql_query ("set names utf8 ");
Mysql_select_db ('1012javab ');
$ Result = mysql_query ("select * from goods ");
While ($ a = mysql_fetch_assoc ($ result )){
$ Arr [] = $;
}
// Instantiate a dom object
$ Doc = new DOMDocument;
// Format the input.
$ Doc-> formatOutput = true;
// Create a root node
$ Books = $ doc-> createElement ('books ');
// Add element nodes
$ Books = $ doc-> appendChild ($ books );
/*
$ Books = $ doc-> appendChild ($ books );
$ Book = $ doc-> createElement ('book ');
$ Books-> appendChild ($ book );
$ Title = $ doc-> createElement ('ttt ');
$ Book-> appendChild ($ title );
*/
Foreach ($ arr as $ key => $ val ){
Echo 11;
$ Book = $ doc-> createElement ('book ');
Foreach ($ val as $ key1 => $ val1 ){
########################### First group
$ Title = $ doc-> createElement ($ key1 );
// Create a file node
$ Content = $ doc-> createTextNode ($ val1 );
$ Title-> appendChild ($ content );
$ Book-> appendChild ($ title );
}
$ Books-> appendChild ($ book );
}
If ($ doc-> save ('goods. XML ')){
Echo 'yes ';
} Else {
Echo 'no ';
}
/*
$ Doc = new DOMDocument ('1. 0 ');
// We want a nice output
$ Doc-> formatOutput = true;
$ Root = $ doc-> createElement ('book ');
$ Root = $ doc-> appendChild ($ root );
$ Title = $ doc-> createElement ('title ');
$ Title ...... remaining full text>
Php file output xml, ie only displays value without element name
Normally, new browsers should all have this automatic parsing function, which is w3c standard.
You can view the source file by yourself.
Examples in this article describes the solutions for php to output xml headers. Share it with you for your reference. The specific method is as follows: Problem description...