Latest web development tutorials

XML on the server

XML files are plain text files similar to HTML files.

XML through a standard Web server can easily store and generation.

XML files are stored on the server

XML files are stored on the Internet server exactly the same way as HTML files.

Start Windows Notepad and write the following lines:

<?xml version="1.0" encoding="ISO-8859-1"?>
<message>Remember me this weekend</message>

Then use the appropriate file name, such as "note.xml", save this file on the Web server.

XML generated by ASP

XML can without installing any software to generate XML on the server side.

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

response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<message>Remember me this weekend</message>")

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

See how the ASP file is returned from the server .

If you want to learn ASP, please on our home page to find ASP tutorial.

Generate XML with PHP

To use PHP to generate an XML response from the server, please use the following code:

header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
echo "<note>";
echo "<from>Jani</from>";
echo "<to>Tove</to>";
echo "<message>Remember me this weekend</message>";
echo "</note>";

Please note that the content-type response header must be set to "text / xml".

Show how PHP files returned from the server .

If you want to learn PHP, please our home page to find PHP tutorials.

XML generated from a database

XML can be generated from the 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:

response.ContentType = "text/xml"
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0;" server.mappath("/db/database.mdb")

sql="select fname,lname from tblGuestBook"
set rs=Conn.Execute(sql)

response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
while (not rs.EOF)
response.write("<fname>" & rs("fname") & "</fname>")
response.write("<lname>" & rs("lname") & "</lname>")


See actual database file output than ASP .

The example above uses ASP with ADO in.

If you want to learn ASP and ADO, please on our home page to find tutorials.

On the server via XSLT transform XML

The following ASP code on the server to XML files into XHTML:

'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false

'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false

'Transform file

Examples explained

  • The first block of code creates an instance of Microsoft's XML parser (XMLDOM), and the XML file into memory.
  • The second block of code creates another instance of the parser, and the XSL file into memory.
  • Finally, the code uses a XSL document to transform XML documents, XHTML and the results sent to your browser.

Take a look at how to run the above code .

By ASP saved XML file

The ASP instances create a simple XML document and saves the document to the server:

text=text & "<to>Tove</to>"
text=text & "<from>Jani</from>"
text=text & "<heading>Reminder</heading>"
text=text & "<body>Don't forget me this weekend!</body>"
text=text & "</note>"

set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")