Transforming XML with XSLT on the Server

by satheesh 2010-02-04 19:53:52

Transforming XML with XSLT on the Server
****************************************

This ASP transforms an XML file to XHTML on the server:
<%
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("simple.xml"))

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

'Transform file
Response.Write(xml.transformNode(xsl))
%>

Example explained

* 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!

Tagged in:

847
like
0
dislike
0
mail
flag

You must LOGIN to add comments