Converting arrays, structures, queries, and components to XML in Coldfusion

Back in 2008 I needed a way to convert mixed CF data into XML documents. I had seen Ray Camden’s “toXML” script, but the functionality was too limited for me. I had to write my own from scratch that not only gave me full control over the creation of the XML document, but also allowed me to send in all of the Coldfusion datatypes, including cfc components. The results was AnythingToXML.

Example Code:






#myXML#

The results would look something like:



    Doll
    $10.00


    Game
    $16.00


    Puzzle
    $12.00


If you structure your data and then pass it to AnythingToXML along with the optional Root Node name and optional list of XML attributes. AnythingToXML will convert your data to a complex and well-formatted XML documents. It will accept any combination of Arrays, Queries, Structures, Objects, and Simple Types as input.

Future upgrades include adding schema and namespace support.

You can download AnythingToXML Here
More Examples of using AnythingToXML are Here

Leave a Reply

Your email address will not be published. Required fields are marked *