Wednesday, May 23, 2007

Pretty XML formatting using XSLT and Coldfusion

Code generated XML can be pretty ugly, i spent a little while googling trying to find an simple answer on how to pretty up xml with CFMX.

The answer? XSLT

Grab this XSLT script Pretty Print XML using XSLT, and load it into a variable like xlst_pretty_print.

Then using the xmltransform function #xmlTransform(xml_str,xlst_pretty_print)# you can get get nice formatted xml out.

hopefully this saves someone else a little time :)

1 comment:

Anonymous said...

I spent hours trying to figure out how to format the XML after an ArrayAppend in Coldfusion. My eyes were burning from searching for so long and then I found your code! What a brain-saver...Awesome!