XML getting started Tutorial: XML on the server

Source: Internet
Author: User

 
XML can be generated on the server without installing any XML controls.

Store XML on the server

XML files can be stored on servers. They are stored in the same way as HTML files.

Start Windows notepad and write the following code:

Reference content is as follows:
<? Xml version = "1.0" encoding = "ISO-8859-1"?>

<Note>

<From> Jani </from>

<To> Tove </to>

<Message> Remember me this weekend </message>

</Note>

Name the file "note. xml" and save it on your server.

Use ASP to generate XML

XML can be generated on the server without installing any XML software.

To generate an XML response from the server, simply write the following code and save it as an ASP file on the server:

Reference content is as follows:
<%

Response. ContentType = "text/xml"

Response. Write ("<? Xml version = 1.0 encoding = ISO-8859-1?> ")

Response. Write ("<note> ")

Response. Write ("<from> Jani </from> ")

Response. Write ("<to> Tove </to> ")

Response. Write ("<message> Remember me this weekend </message> ")

Response. Write ("</note> ")

%>


Note that the content type of this response must be set to "text/xml ".

Get XML from database

XML can be generated from the database without installing any XML software.

To generate an XML database response from the server, simply write the following code and save it as an ASP file on the server:

Reference content is as follows:

<%

Response. ContentType = "text/xml"

Set conn = Server. CreateObject ("ADODB. Connection ")

Conn. provider = "Microsoft. Jet. OLEDB.4.0 ;"

Conn. open server. mappath ("/db/database. mdb ")

SQL = "select fname, lname from tblGuestBook"

Set rs = Conn. Execute (SQL)

Rs. MoveFirst ()

Response. write ("")

Response. write ("<guestbook> ")

While (not rs. EOF)

Response. write ("<guest> ")

Response. write ("<fname>" & rs ("fname") & "</fname> ")

Response. write ("<lname>" & rs ("lname") & "</lname> ")

Response. write ("</guest> ")

Rs. MoveNext ()

Wend

Rs. close ()

Conn. close ()

Response. write ("</guestbook> ")

%>

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.