The XML file stored on the server can be stored on the network server. Like other HTML files, XML files can be stored on network servers. You can create an XML document on the server without installing the XML control.
--------------------------------------------------------------------------------
Store XML documents on the server
XML files can be stored on network servers.
Like other HTML files, XML files can be stored on network servers.
Open your notepad and write the following code:
Small shard
Kobayashi
Let's go to the hot pot together in the evening.
Save the file to your server and name it "note. xml ".
Note: the XML file must be in the same directory as other HTML files, and the MIME type should be set to text/xml.
--------------------------------------------------------------------------------
Use ASP to generate XML files
XML files can be generated on the server even if XML software is not installed.
To enable the server to generate dynamic XML responses to the client, we can create a simple ASP page containing the following code on the server:
<% Response. ContentType = "text/xml" response. Write ("
") Response. Write ("
") Response. Write ("
Small shard
") Response. Write ("
Kobayashi
") Response. Write ("
Let's go to the hot pot together in the evening.
") Response. Write ("
") %>
Note: The XML content must be set correctly. Check the ASP page. if the server supports ASP, the displayed content is the same as that of the note. xml file.
--------------------------------------------------------------------------------
Generate XML documents from the database
You can dynamically Export XML documents from the database without installing any XML software.
We can retrieve data from the database by slightly modifying the previous example.
The following is an example of an ASP page that dynamically generates XML data on the server:
<%response.ContentType = "text/xml"set conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0;"conn.open server.mappath("../ado/database.mdb")sql="select fname,lname from tblGuestBook"set rs=Conn.Execute(sql)rs.MoveFirst()response.write("
")response.write("
")while (not rs.EOF)response.write("
")response.write("
" & rs("fname") & "
")response.write("
" & rs("lname") & "
")response.write("
")rs.MoveNext()wendrs.close()conn.close()response.write("
")%>
The above is the details of the sample code for XML data exchange. For more information, see other related articles in the first PHP community!