XML files are plain text files just like HTML files.
XML can easily be stored and generated by a standard web server.
Storing XML Files on the Server
XML files can be stored on an Internet server exactly the same way as HTML files.
Start Windows Notepad and write the following lines:
Save the file on your web server with a proper name like "note.xml".
Generating XML with ASP
XML can be generated on a server without any installed XML software.
To generate an XML response from the server - simply write the following code and save it as an ASP file on the web server:
Note that the content type of the response must be set to "text/xml".
If you want to study ASP, you will find our ASP tutorial on our homepage.
Generating XML with PHP
To generate an XML response from the server using PHP, use following code:
Note that the content type of the response header must be set to "text/xml".
If you want to study PHP, you will find our PHP tutorial on our homepage.
Generating XML From a Database
XML can be generated from a database without any installed 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 web server:
The example above uses ASP with ADO.
If you want to study ASP and ADO, you will find the tutorials on our homepage.
Transforming XML with XSLT on the Server
This ASP transforms an XML file to XHTML on the server:
- The first block of code creates an instance of the Microsoft XML parser (XMLDOM), and loads the XML file into memory.
- The second block of code creates another instance of the parser and loads the XSL file into memory.
- The last line of code transforms the XML document using the XSL document, and sends the result as XHTML to your browser. Nice!
Saving XML To a File Using ASP
This ASP example creates a simple XML document and saves it on the server: