By now I'm sure you're probably using XML files for something. Whether it be data transfer,
storage, caching, or something else altogether, it's a great technology. Anyway, my point
is that you've probably got a few XML files lying around your website. While XML
is designed to be human readable as much as it is machine readable, sometimes it's nice to
look at something without the <>'s.
This little script will take an XML file and an XSL file and combine them to produce whatever
output you want. The sample files (xmlxsl.xml and xmlxsl.xsl)
contain a copy of some of our fake sample data and convert it to a basic HTML table, but you
can use the same code to transform your data into whatever you want... just change the stylesheet.
Using Remote XML/XSL Files
If you're going to be pulling either the XML of XSL file from a remote server, you should
take a look at the remote version of this sample: XML to HTML (via XSL) - Remote Files.
Update: Common Functions for Working with XML and XSL Files
One of our readers read our sample and decided to share a few functions that he's been using
to handle his XML and XSL needs. Here's his email:
I've just looked at XML to HTML (via XSL) Classic ASP Sample, and I realised that
I've written a few (5) functions for doing this, but with a few enhancements
You can do everything in one function call
The more complicated functions call the simpler ones, keeping everything clean
You can pass parameters into your stylesheet straight from the function call
Here is the pure file (complete with pseudo XML comments) - I'll write up a
little guide to the code if you like it. It's not doing anything special, but
I don't think I've noticed anything quite like it being posted before.
Thanks
Chris Surfleet
No Chris... Thank You! I sure many of our users will find the functions extremely
helpful. Oh and speaking of the functions, here they are: server-xml.zip (1 KB).
Like Chris said, they're pretty simple to figure out and there are basic comments
included with the source. Thanks again Chris.