[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

URGENT: Coldfusion to XML

Posted on 2006-04-04
7
Medium Priority
?
204 Views
Last Modified: 2013-12-24
Hi guys, i need code that when i get info from my database that it turns it into an xml file on the fly onto the server, so i can use this for rss feeds! i have a table called completed this would be the query that i would use to show my data:

<cfquery name="addcbook" datasource="mybook">
select * from completed
  </cfquery>

the table fields are: bname,date,bauthor,bookss,bidss

Thanks,

Ian.
0
Comment
Question by:Ianaldo
4 Comments
 
LVL 12

Accepted Solution

by:
mkishline earned 2000 total points
ID: 16376672
<cfsavecontent variable="body">
      <cfoutput query="addcbook">
      <item>
            <bname>#bname#</bname>
            <date>#date#</date>
            <bauthor>#bauthor#</bauthor>
            <bookss>#bookss#</bookss>
            <bidss>#bidss#</bidss>
      </item>
      </cfoutput>
</cfsavecontent>

<cfoutput>#body#</cfoutput>
<cffile action="write" file="path_on_server.xml" output="#body#">
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 16377024
Hi know that kinda thing, thanks, but i need it to generate an xml file so that i can use the url of the generated xml file to allow for rss, so i need the whole xml generated, thanks!!
0
 
LVL 18

Expert Comment

by:Plucka
ID: 16378105
mkishline,

What mk has provided would work for you.

Just build up the xml you require, then output the resulting variable (body in this example) at the end. No need to write it to the file.

<cfsavecontent variable="myXml">
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <cfoutput query="addcbook">
        <item>
            <bname>#bname#</bname>
            <date>#date#</date>
            <bauthor>#bauthor#</bauthor>
            <bookss>#bookss#</bookss>
            <bidss>#bidss#</bidss>
        </item>
        </cfoutput>
    </root>
</cfsavecontent>

<cfoutput>#myXml#</cfoutput>

Regards
Plucka
0
 
LVL 3

Expert Comment

by:pcaioo
ID: 16620118
Why the follow: complete code with dynamic variable all variable will show

<cfsetting enablecfoutputonly="yes">
<cfquery name="QueryCheck" datasource=#dbname#>
      SELECT      *
      From      ClientDB
</cfquery>
<cfsetting enablecfoutputonly="no">
<cfparam name="FileName" default="myfilename">      
<cfheader name="Content-Disposition" value="filename=#FileName#">
<xml id="QueryResult">
      <QueryRes><cfoutput query="QueryCheck">
            <QueryRow>
                  <RowCount>#QueryCheck.CurrentRow#</RowCount><cfloop list="#QueryCheck.Columnlist#" index="Fields">
                  <#Fields#>#HTMLeditFormat(evaluate("#Fields#"))#</#Fields#></cfloop>
            </QueryRow></cfoutput>
      </QueryRes>
</xml>
<cfabort>
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

872 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