Free NT Web Hosting, Free ASP Hosting, Free Web hosting, Free Hosting - DomainDLX
    

    Home
    Registration
    FAQs
    Terms of service
    Contact us

    Learn ASP
    Databases
    Articles

When you need to deliver XML based content to non-Internet explorer 5 users, you must apply the XSL on the server side. This means you have to use ASP to do it. Here is an easy ASP function to make that process simpler.

First the code:

Function ApplyXSL(XMLFile,XSLFile)
    If (XMLFile <> "") AND (XSLFile <> "") Then
	'load XML
	Set XMLDoc = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
	XMLDoc.async = false
	XMLDoc.load(Server.MapPath(XMLFile))
	'load xsl stylesheet
	Set XSLDoc = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
	XSLDoc.async = false
	XSLDoc.load(Server.MapPath(XSAFile))
	ApplyXML = XMLDoc.transformNode(XSLDoc)
    Else
	ApplyXML = "XML or XSL not specified"
    End If
End Function

What this function does is open up the XML and XSL files and combine then together with the transformNode() function. Then it returns the resulting HTML code to be either printed out or stored in a variable. Check out the examples below:

Printing out the resulting code:

Response.Write(ApplyXML("mydata.xml","mystyle.xsl"))

Storing it to a variable:

Dim myXML
    myXML = ApplyXML("mydata.xml","mystyle.xsl")