advice needed... cf write data to xml file for use in flash app thatuses xml file

Posted: 11-28-2005, 01:19 AM
I'm wondering if it is possible to use CF to:

1) connect to existing db;
2) get specific data from table;
3) write it to an xml file that would follow a specific format and
include the output data;
4) that a flash newsticker (flashloaded.com's newsticker) could use

I ask because I want to use the flashloaded newsticker app and this
project already has a database and can be hosted on an existing cf
server. So I guess I am asking how hard it would be for qualified cf
developer to write out the data to the xml file? The ticker reads a
static xml file, so if cf can write that, I can tell the project manager
that the solution is feasible and reasonable budget-wise.

I'm no cf developer, but shouldn't you be able to have coldfusion write
a static file using any tags you tell it to, putting the text (data) in
them?

Advice sought and appreciated. thanks!

Donna
Reply With Quote

Responses to "advice needed... cf write data to xml file for use in flash app thatuses xml file"

dr_bozak
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for usein flash app that uses xml file
Posted: 11-28-2005, 04:46 AM
yeah .. this is real easy.

if you have cf 5 or earlier, you can just translate your existing xml doc into
a db, and then write a query, that builds a string and outputs to a file.

in cf 6.1 and later (i think)
you can just tell Cf that you want the query returned as xml


either way, it works easily.
I have only experience with the old method, but it;s not very tough. I think
it took me an hour.



Reply With Quote
Donna Casey
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for use in flashapp that uses xml file
Posted: 11-28-2005, 03:08 PM
dr_bozak wrote:
> yeah .. this is real easy.
>
> if you have cf 5 or earlier, you can just translate your existing xml doc into
> a db, and then write a query, that builds a string and outputs to a file.
>
> in cf 6.1 and later (i think)
> you can just tell Cf that you want the query returned as xml
>
>
> either way, it works easily.
> I have only experience with the old method, but it;s not very tough. I think
> it took me an hour.
>
>
>
Thanks, dr_bozak. What I am wondering about is just the opposite--there
already is a database and an application that is written in CF to query
the data and then put it in an html page... there are also admin pages
to write to the database (to add content)

Instead, I want to display that same data from the cf query in the
flashloaded.com newsticker app, which reads an xml file. So, the
question is how feasible it is to get CF to query the db and write out
that data into the xml page or, if easier, to simply create the xml page
with the required tags and data?

The xml file uses the typical assortment of tags:

<?xml version="1.0" ?>
<ticker>
<topic>
<text>
<![CDATA[
<b>June 28, 2005 <br /><font color="#FFFFFF">blah,
blah</font></b><br><i>blah, blah</i>]]>
</text>
<link>http://www.mydomain.com/whereever.cfm</link>
<target>_self</target>
<targetIsUrl>Y</targetIsUrl>
</topic>
</ticker>

Possible?

tia, Donna

Reply With Quote
Donna Casey
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for use in flashapp that uses xml file
Posted: 11-28-2005, 03:14 PM
What I am curious about is whether CF can

1) write to an existing xml file?
2) write a new xml file?
3) what is the method used assuming the general assortment of data, like
#tickerdate# #tickernewstext# and #tickerlink#, blah, blah?

I am assuming that it actually writes the content, but can it also write
the necessary tags required by the flash app, or would you use some sort
of template that already has those or would you concactenate the tags
with the data references to produce a string that is then written to an
xml file?

Like I said, I'm no backend developer, but I have a general picture of
how it works and just want to be solid in saying what will or won't work
and how.

thanks so much all,
Donna
Reply With Quote
dr_bozak
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for usein flash app that uses xml file
Posted: 11-28-2005, 03:41 PM
1) write to an existing xml file?

2) write a new xml file?
3) what is the method used assuming the general assortment of data, like
#tickerdate# #tickernewstext# and #tickerlink#, blah, blah?

I am assuming that it actually writes the content, but can it also write
the necessary tags required by the flash app, or would you use some sort
of template that already has those or would you concactenate the tags
with the data references to produce a string that is then written to an
xml file?

Like I said, I'm no backend developer, but I have a general picture of
how it works and just want to be solid in saying what will or won't work
and how.

thanks so much all,
Donna


Reply With Quote
dr_bozak
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for usein flash app that uses xml file
Posted: 11-28-2005, 03:54 PM
1) write to an existing xml file?
* Yes. you use cffile to do this.
2) write a new xml file?
* again, you use CFFILE to do this

3) what is the method used assuming the general assortment of data, like
#tickerdate# #tickernewstext# and #tickerlink#, blah, blah?
* as I mentioned, you can query your db to retrieve the data in your existing
DB, and write it out as XML to match your existing document.

I am assuming that it actually writes the content, but can it also write
the necessary tags required by the flash app,
*tags aside from XML?

or would you use some sort
of template that already has those or would you concactenate the tags
with the data references to produce a string that is then written to an
xml file?
* thats the old school way to do it. which is how I did it, (pre MX)

check out how I did it: this is coming from a single table, but should show
you one method. again, with CFMX there is cleaner way to do it (although this
method for me produced a pretty xml doc that looked right, but must have had
extra charcters in it, as it didn't work)


<!----- heres the code ---->

<cfset thisDS = "everb">
<cfquery datasource="#thisDS#" name="getSeasons">
Select * FROM seasons order by id DESC
</cfquery>

<cfset thisString = "<?xml version=""1.0""
encoding=""UTF-8""?><everb><seasons>">
<cfloop query="getSeasons">
<cfset currentSeason = (getSeasons.recordcount+1) - getSeasons.currentrow>
<cfquery datasource="everb" name="getSeasonPics">
Select images.image, images.id from images, seasonImage, seasons
where images.id = seasonimage.imgid AND seasonImage.seasonID = seasons.id
AND seasons.id = #getSeasons.id# order by images.id ASC
</cfquery>
<cfset thisString = thisString & "<season idName=""#seasonname#""
id=""#currentSeason#"">">
<cfloop query="getSeasonPics">
<cfset thisString = thisString & "<img>#image#</img>">
</cfloop>
<cfset thisString = thisString & "</season>">
</cfloop>
<cfset thisString = thisString & "</seasons><main><nav idName=""everB
Profile""></nav><nav idName=""Stores""></nav><nav
idName=""Contact""></nav></main></everb>">


<cffile action="write" file="#thepath#\everb.xml" nameconflict="overwrite"
output="#thisString#">
</cffile>

<!--- end of code ---->


and here is the xml it made from the db ....

<?xml version="1.0" encoding="UTF-8"?><everb><seasons><season idName="season5"
id="5"><img>crypto_snap.jpg</img><img>crypto_success.jpg</img></season><season
idName="pwned" id="4"><img>IMG_605.jpg</img></season><season idName="season3"
id="3"><img>ebt07.jpg</img><img>ebt14a.jpg</img><img>ebt14b.jpg</img></season><s
eason idName="Fresh"
id="2"><img>ebs01.jpg</img><img>ebt09.jpg</img></season><season idName="You own
dawg"
id="1"><img>ebj01.jpg</img><img>ebt02.jpg</img><img>ebt03.jpg</img></season></se
asons><main><nav idName="everB Profile"></nav><nav idName="Stores"></nav><nav
idName="Contact"></nav></main></everb>



let me know if that helps. You can defintely do what you are asking, and I'm
pretty sure I understand.
you have existing db and cf queries, that you want to use to create an XML doc
that will be later read by flash. the xml doc created needs to match the format
exactly to feed the flash movie.

the above example will show you the old way.

the new way ....

well ...

type xml coldfusion into google, or check out the livedocs example for MX.






Reply With Quote
Donna Casey
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for use in flashapp that uses xml file
Posted: 11-28-2005, 04:58 PM
Thanks! I haven't had time to check this out, but it looks like what I
thought would work. When I get time to put it together, I'll get back to
you with the results...

I'd give you my first-born, but she's 27 and her husband might object!

donna

dr_bozak wrote:
> 1) write to an existing xml file?
> * Yes. you use cffile to do this.
> 2) write a new xml file?
> * again, you use CFFILE to do this
>
> 3) what is the method used assuming the general assortment of data, like
> #tickerdate# #tickernewstext# and #tickerlink#, blah, blah?
> * as I mentioned, you can query your db to retrieve the data in your existing
> DB, and write it out as XML to match your existing document.
>
> I am assuming that it actually writes the content, but can it also write
> the necessary tags required by the flash app,
> *tags aside from XML?
>
> or would you use some sort
> of template that already has those or would you concactenate the tags
> with the data references to produce a string that is then written to an
> xml file?
> * thats the old school way to do it. which is how I did it, (pre MX)
>
> check out how I did it: this is coming from a single table, but should show
> you one method. again, with CFMX there is cleaner way to do it (although this
> method for me produced a pretty xml doc that looked right, but must have had
> extra charcters in it, as it didn't work)
>
>
> <!----- heres the code ---->
>
> <cfset thisDS = "everb">
> <cfquery datasource="#thisDS#" name="getSeasons">
> Select * FROM seasons order by id DESC
> </cfquery>
>
> <cfset thisString = "<?xml version=""1.0""
> encoding=""UTF-8""?><everb><seasons>">
> <cfloop query="getSeasons">
> <cfset currentSeason = (getSeasons.recordcount+1) - getSeasons.currentrow>
> <cfquery datasource="everb" name="getSeasonPics">
> Select images.image, images.id from images, seasonImage, seasons
> where images.id = seasonimage.imgid AND seasonImage.seasonID = seasons.id
> AND seasons.id = #getSeasons.id# order by images.id ASC
> </cfquery>
> <cfset thisString = thisString & "<season idName=""#seasonname#""
> id=""#currentSeason#"">">
> <cfloop query="getSeasonPics">
> <cfset thisString = thisString & "<img>#image#</img>">
> </cfloop>
> <cfset thisString = thisString & "</season>">
> </cfloop>
> <cfset thisString = thisString & "</seasons><main><nav idName=""everB
> Profile""></nav><nav idName=""Stores""></nav><nav
> idName=""Contact""></nav></main></everb>">
>
>
> <cffile action="write" file="#thepath#\everb.xml" nameconflict="overwrite"
> output="#thisString#">
> </cffile>
>
> <!--- end of code ---->
>
>
> and here is the xml it made from the db ....
>
> <?xml version="1.0" encoding="UTF-8"?><everb><seasons><season idName="season5"
> id="5"><img>crypto_snap.jpg</img><img>crypto_success.jpg</img></season><season
> idName="pwned" id="4"><img>IMG_605.jpg</img></season><season idName="season3"
> id="3"><img>ebt07.jpg</img><img>ebt14a.jpg</img><img>ebt14b.jpg</img></season><s
> eason idName="Fresh"
> id="2"><img>ebs01.jpg</img><img>ebt09.jpg</img></season><season idName="You own
> dawg"
> id="1"><img>ebj01.jpg</img><img>ebt02.jpg</img><img>ebt03.jpg</img></season></se
> asons><main><nav idName="everB Profile"></nav><nav idName="Stores"></nav><nav
> idName="Contact"></nav></main></everb>
>
>
>
> let me know if that helps. You can defintely do what you are asking, and I'm
> pretty sure I understand.
> you have existing db and cf queries, that you want to use to create an XML doc
> that will be later read by flash. the xml doc created needs to match the format
> exactly to feed the flash movie.
>
> the above example will show you the old way.
>
> the new way ....
>
> well ...
>
> type xml coldfusion into google, or check out the livedocs example for MX.
>
>
>
>
>
>
Reply With Quote
Donna Casey
Guest
Posts: n/a
 
Re: advice needed... cf write data to xml file for use in flashapp that uses xml file
Posted: 11-30-2005, 09:38 PM
Hello, again, dr_bozak
I'm taking a look at this now and I think I understand it. My question is :
Do I put my modified version (with my ds, query and xml requirements) in
the HEAD of the page that runs the flash app that reads the resulting
xml file?
Or would the database need to be queried before the flash app page is
loaded into the browser (for example, the flash app will be an element
on the homepage of the site, so would it run as the homepage loads or do
I send the user through another page that triggers the xml file write
and directs the user to the "real" homepage)?

Donna

dr_bozak wrote:
> 1) write to an existing xml file?
> * Yes. you use cffile to do this.
> 2) write a new xml file?
> * again, you use CFFILE to do this
>
> 3) what is the method used assuming the general assortment of data, like
> #tickerdate# #tickernewstext# and #tickerlink#, blah, blah?
> * as I mentioned, you can query your db to retrieve the data in your existing
> DB, and write it out as XML to match your existing document.
>
> I am assuming that it actually writes the content, but can it also write
> the necessary tags required by the flash app,
> *tags aside from XML?
>
> or would you use some sort
> of template that already has those or would you concactenate the tags
> with the data references to produce a string that is then written to an
> xml file?
> * thats the old school way to do it. which is how I did it, (pre MX)
>
> check out how I did it: this is coming from a single table, but should show
> you one method. again, with CFMX there is cleaner way to do it (although this
> method for me produced a pretty xml doc that looked right, but must have had
> extra charcters in it, as it didn't work)
>
>
> <!----- heres the code ---->
>
> <cfset thisDS = "everb">
> <cfquery datasource="#thisDS#" name="getSeasons">
> Select * FROM seasons order by id DESC
> </cfquery>
>
> <cfset thisString = "<?xml version=""1.0""
> encoding=""UTF-8""?><everb><seasons>">
> <cfloop query="getSeasons">
> <cfset currentSeason = (getSeasons.recordcount+1) - getSeasons.currentrow>
> <cfquery datasource="everb" name="getSeasonPics">
> Select images.image, images.id from images, seasonImage, seasons
> where images.id = seasonimage.imgid AND seasonImage.seasonID = seasons.id
> AND seasons.id = #getSeasons.id# order by images.id ASC
> </cfquery>
> <cfset thisString = thisString & "<season idName=""#seasonname#""
> id=""#currentSeason#"">">
> <cfloop query="getSeasonPics">
> <cfset thisString = thisString & "<img>#image#</img>">
> </cfloop>
> <cfset thisString = thisString & "</season>">
> </cfloop>
> <cfset thisString = thisString & "</seasons><main><nav idName=""everB
> Profile""></nav><nav idName=""Stores""></nav><nav
> idName=""Contact""></nav></main></everb>">
>
>
> <cffile action="write" file="#thepath#\everb.xml" nameconflict="overwrite"
> output="#thisString#">
> </cffile>
>
> <!--- end of code ---->
>
>
> and here is the xml it made from the db ....
>
> <?xml version="1.0" encoding="UTF-8"?><everb><seasons><season idName="season5"
> id="5"><img>crypto_snap.jpg</img><img>crypto_success.jpg</img></season><season
> idName="pwned" id="4"><img>IMG_605.jpg</img></season><season idName="season3"
> id="3"><img>ebt07.jpg</img><img>ebt14a.jpg</img><img>ebt14b.jpg</img></season><s
> eason idName="Fresh"
> id="2"><img>ebs01.jpg</img><img>ebt09.jpg</img></season><season idName="You own
> dawg"
> id="1"><img>ebj01.jpg</img><img>ebt02.jpg</img><img>ebt03.jpg</img></season></se
> asons><main><nav idName="everB Profile"></nav><nav idName="Stores"></nav><nav
> idName="Contact"></nav></main></everb>
>
>
>
> let me know if that helps. You can defintely do what you are asking, and I'm
> pretty sure I understand.
> you have existing db and cf queries, that you want to use to create an XML doc
> that will be later read by flash. the xml doc created needs to match the format
> exactly to feed the flash movie.
>
> the above example will show you the old way.
>
> the new way ....
>
> well ...
>
> type xml coldfusion into google, or check out the livedocs example for MX.
>
>
>
>
>
>
Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Flash save data from a text file locally zero_skill Macromedia Flash Data Integration 6 11-12-2005 01:00 PM
Flash file imports data with XML iOXeR Macromedia Flash Data Integration 6 07-13-2005 07:48 PM
Flash RIA - XML Display Advice Needed crpatrick Macromedia Flash Data Integration 1 07-01-2005 07:54 AM
can director write xml file? Joan Delacourt Macromedia Director Basics 0 07-03-2003 08:31 AM
Write line at beginning of file? Tad McClellan PERL Miscellaneous 2 06-26-2003 06:37 PM