Creating an XML file with ColdFusion

Posted on 2007-10-04
Last Modified: 2013-12-24
I need to loop through a query to create an xml file. How do I create a file using CF? I thought maybe cffile but I don't see an attribute for "new", just things like append, delete, move etc... Am I missing something here? I've used cfheader to send content to the browser but just not sure how to create a file and place in on the server.

Any help would be appreciated GREATLY!!!!
Question by:IRHusker
    LVL 4

    Expert Comment

    <cfsaveconent variable="xmlString">

    <cffile action = "write" file = "c:\myXml.xml" output="#xmlString#">

    Author Comment

    Thanks Russell!

    When I try this approach I get the following error:
    "Context validation error for tag cfsavecontent.  
    The end tag </cfsavecontent> encountered on line 28 at column 3 requires a matching start tag.  "

    At first I thought it was the XML I was trying to insert there but even if I remove all content in the <!--- XML CREATION CODE HERE---> section I still get the error.  The XML als test fine on it's own.  

    Any thoughts?
    LVL 4

    Accepted Solution

    There is a spelling error in my code... correct the spelling for the opening tag...

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    The viewer will learn how to dynamically set the form action using jQuery.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now