Category: VBScript
Transforming XML Server-Side
Angela and I gave a presentation to the Mid-Michigan CFUG yesterday (well actually Angela gave the presentation, and I just showed some XSL stuff), and I showed everyone how to use the new XSLT visual authoring tools in Dreamweaver 8. They're great and wonderful and everything, but they're really geared towards working with local XML files. The reason I say that, is that Macromedia doesn't offer any solutions for transforming a remote XML file. They allow you to write an XSLT file to transform that remote content, but they don't tell you how to actually pull a little Optimus Prime on it and make that XML human readable.
So, I thought I'd share some code to make this happen. It's ridiculously simply once you see it, but I've run into quite a few people that just haven't been able to put all of the pieces together. So, here's some ColdFusion code to grab MM's DesDev feed and transform it using an XSL file on your own server:
<cfsilent> <cfhttp url="http://weblogs.macromedia.com/dev_center/index.rdf" method="get" /> <cfset xmlObj = XMLParse(cfhttp.FileContent) /> <cfset xslPath = ExpandPath("mmdesdev.xsl") /> <cffile action="read" variable="xsl" file="#xslPath#" /> </cfsilent> <cfoutput>#XMLTransform(xmlObj, xsl)#</cfoutput>
Yep, believe it or not, that's all that it takes. You just read in the XML file from the server somewhere out there in internet land, convert it to an XML Object using XMLParse, and then read the XSL file from the server, and transform it all using the XMLTransform function. Can I say I love ColdFusion? Here's the same work done with ASP:
<% Dim xmlDocument, xslDocument set xmlDocument = Server.CreateObject("MSXML2.DOMDocument.4.0") set xslDocument = Server.CreateObject("MSXML2.DOMDocument.4.0") xmlDocument.async = false xmlDocument.setProperty "ServerHTTPRequest", true xmlDocument.load("http://weblogs.macromedia.com/dev_center/index.rdf") xslDocument.async = false xslDocument.load(Server.MapPath("mm.xsl")) Response.Write xmlDocument.transformNode(xslDocument.documentElement) %>
Cartweaver 2 PHP Released!
Finally, I can get a good night's sleep :). Cartweaver 2 PHP, a PHP shopping cart solution for Dreamweaver, is now for sale. Get your PHP on, and buy one today!
Tom Muck is the PHP developer on this one, I'm just there for moral support :)
March Mingle MADNESS!!!
If you're down in the LA/San Diego area, I'm going to be infiltrating the March Mingle on Monday. If you're a Cartweaver'er (or something) just look for me in my fancy Cartweaver shirt and say hello. There are going to be some good giveaways, and there should be a lot of geek-ness going on. You can find out some more details on what's being given away at Angela's blog.
See ya there!