PHP generates XML. I use this code to generate xml & lt ;? Php & nbsp; include ("conn/conn. php "); & nbsp; $ path & nbsp; = & nbsp; 'XML/createxml. xml '; & nbsp; if (file_exists ($ path) & nbsp; unl PHP generates XML
I use this code to generate xml
Include ("conn/conn. php ");
$ Path = 'XML/createxml. XML ';
If (file_exists ($ path) unlink ($ path );
$ Handle = fopen ($ path, 'w ');
$ XmlContent. =' ';
$ XmlContent. =' ';
// Query all sections
$ Select1 = $ _ POST ['select1'];
$ Select2 = $ _ POST ['select2'];
Echo $ select1;
Echo $ select2;
$ Query = "select * from tb_car where car_road like '% $ select1 %' and car_road like '% $ select2 % '";
$ Result = mysql_query ($ query );
If (mysql_num_rows ($ result)> 0 ){
While ($ myrow = mysql_fetch_array ($ result )){
$ XmlContent. =' ';
$ XmlContent. =' ';
$ XmlContent. =' ';
$ XmlContent. =' ';
$ XmlContent. =' ';
}
}
$ XmlContent. ='';
If ($ handle)
{
If (fwrite ($ handle, $ xmlContent ))
{
Fclose ($ handle );
}
Echo "script window. location. href = 'indexs. php? Lmbs = car source information query & select1 = $ select1 & select2 = $ select2 '; script ";
}
?>
----
Why is the location of the generated xml data and value changed?
-
-
-
-
------ Solution --------------------
Xml generation is like this. you can write dtd file constraints.
------ Solution --------------------
$ XmlContent. ='';
Echo $ xmlContent; exit (); try
------ Solution --------------------
Reference:
Xml generation is like this. you can write dtd file constraints.
Can the order of attributes be defined ?? How should I fix it ??
------ Solution --------------------
Http://www.w3school.com.cn/dtd/index.asp
------ Solution --------------------
Hello, I just read your code and the results are quite strange.
I noticed the sixth line of your code: $ xmlContent. =' ';
I found that your variable is neither defined nor assigned a value. you should remove the Connector "." and you should remove it for testing.
Bytes -------------------------------------------------------------------------------------------------------------------
I remember that the xml dtd (Document Type Definition) can standardize the order of definition, but it can only specify the order of elements. As for the order of attributes, I just tested it, it seems useless, but I wrote a DTD for you. you can try it.
]>
……
Bytes -------------------------------------------------------------------------------------------------------------------
If you want to get rid of it, you can also try the DOMDocument () class that specifically operates XML.
Try it. I hope it will be useful to you.