xml| Server
XML can be generated on a server that does not have any XML controls installed.
Storing XML on the server
The XML file can be stored on your Internet server. The XML file can be stored on your Internet server, just like any other HTML file.
Open the Notepad editor and write the following lines:
< XML version= "1.0"?>
< note>
< from>jani</from>
< to>tove</to>
< Message>remember me this weekend</message>
</note>
You just need to use an appropriate name such as "Note.xml" to store the file on your Internet server, and then the XML document will be available. Note: The XML file must be in the same path (folder) as your HTML file, and the MIME type of the XML file should be set to Text/xml.
Generating XML with ASP
XML can be generated on a server that does not have any XML software installed. To generate an XML response from your server-just write the following code and save it on your Web server as an ASP file:
<%
Response.contenttype= "Text/xml"
Response.Write ("< XML version= ' 1.0 '?>")
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: The content type of the response must be set to XML. Click here to see how to return ASP files from the server. (ASP represents the Active Server page.) If you don't know how to write ASP, you can learn on W3Schools ' ASP School
Get XML from a database
XML can be generated from a database that does not have any XML software installed. The XML response in the previous example can easily be modified to retrieve its data from a database. To generate an XML database response from a database, you only need to write the following code and save it as an ASP file:
<%
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 ("< XML version= ' 1.0 '?>")
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>")
%>
You can try the actual database output for this page yourself. The example above uses an ASP with ADO. If you don't know how to use ADO, you can learn in W3Schools ' ADO School.