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> ")
%>