September 3rd, 2010
I feel I’ve now earned the particular distinction of having participated in a cage match with an XML file and beaten its bloody face in. Sure, they’re pretty nifty for storing collections of data and laying them out on web sites, but you don’t get the full experience until you have to create a web interface to edit, insert, delete, and sort said XML file. Honestly, it would have been easier just to store the data in a PHP array. But hell, I love a good cage match! My biggest problem was that anytime I would edit or insert an event element, it would appear in the XML file as the last node rather than in date order. I figured out how to sort the XML contents as they were rendered in HTML using an XSLT (EXtensible Stylesheet Language Transformation). This worked fine for one display but sadly, this XML needed to be displayed several different ways in different places and I wasn’t thrilled with the thought of having to create an XSL file for every variation. All I really needed was one XSL file to sort the XML data each time it was updated. So I wrapped rope around my hands, coated them with resin, dipped them in broken glass, and stepped into the cage.
Posted in PHP Scripts | 10 Comments »