The error code returned by responseXML is as follows: & lt ;? Php & nbsp; header ('content-Type: text/XML'); header (& quot; Cache-Control: no-cache, must-revalidate & q responseXML cannot get results
The code is as follows:
Header ('content-Type: text/XML ');
Header ("Cache-Control: no-cache, must-revalidate ");
$ Q = $ _ GET ["q"];
// Include_once ("../public/dbManager. php ");
// Include_once ("../public/stringConvert. php ");;
$ Con = mysql_connect ('localhost', 'root', 'root ');
If (! $ Con ){
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("ajax_demo", $ con );
$ SQL = "SELECT * FROM user WHERE id =". $ q ."";
$ Result = mysql_query ($ SQL );
Echo'
';
While ($ row = mysql_fetch_array ($ result )){
Echo" ". $ Row ['firstname']." ";
Echo" ". $ Row ['lastname']." ";
Echo "". $ row ['age']."";
Echo" ". $ Row ['Hometown ']." ";
Echo" ". $ Row ['job']." ";
}
Echo" ";
Mysql_close ($ con );
?>
The above code only requires the introduction of other files and comments
// Include_once ("../public/dbManager. php ");
// Include_once ("../public/stringConvert. php ");
.
ResponseXML will not be able to get the result, and execute to xmlDoc. getElementsByTagName ("firstname") [0]. childNodes [0]. nodeValue;
The program is no longer executed.
If the include statement is removed, the program runs normally.
The file introduced above does not have any page output.
I just got in touch with php. please answer this question. thank you.
------ Solution --------------------
Let's see if XML is returned correctly.
------ Solution --------------------
PHP array and xml mutual conversion encapsulation function: xmlparse. php
PHP code
# Convert the array to xmlinclude (dirname (_ FILE __). "/xmlparse. php "); $ listtags = explode (" "," name "); $ arr = array (1," name "=>" SOM "," admin ", 100, array ("name" => "TOM", "Lily"); $ contXML = dump_xml_config ($ arr, "xml", "UTF-8 "); // put the file // file_put_contents_safe ("/path/test. xml ", $ contXML," w "); echo $ contXML; # Source code #
#
# <0> 1
#
SOM
# <1> admin
<2> 100
# <3> #
TOM
# <0> Lily
#
#
------ Solution --------------------
Header ('content-Type: text/XML ');
Header ("Cache-Control: no-cache, must-revalidate ");
Comment out the two sentences. Open the included files. Enable the error prompt function to check whether an error is returned.