XML on Server
XML files are plain text files similar to HTML files.
XML can be easily stored and generated through standard web servers.
Storing XML Files on the Server
XML files are stored on Internet servers in the same way as HTML files.
Start Windows Notepad and write the following lines:
Then save this file on the web server with an appropriate filename, such as "note.xml".
Generating XML via ASP
XML can be generated on the server side 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 web server:
Note that the content type of this response must be set to "text/xml".
View how this ASP file returns from the server.
If you want to learn ASP, find the ASP tutorial on our homepage.
Generating XML via PHP
To generate an XML response from the server using PHP, use the following code:
Note that the content type of the response header must be set to "text/xml".
View how this PHP file returns from the server.
If you want to learn PHP, find the PHP tutorial on our homepage.
Generating XML from a Database
XML can be generated from a 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 web server:
View the actual database output of the above ASP file.
The above example uses ASP with ADO.
If you want to learn ASP and ADO, find the relevant tutorials on our homepage.
Transforming XML with XSLT on the Server
The following ASP code transforms an XML file into XHTML on the server:
Example Explanation
The first code block creates an instance of the Microsoft XML parser (XMLDOM) and loads the XML file into memory.
The second code block creates another instance of the parser and loads the XSL file into memory.
The last code uses the XSL document to transform the XML document and sends the result as XHTML to your browser.
Saving XML as a File via ASP
This ASP example creates a simple XML document and saves it to the server: