Sample code for XML data exchange

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.