Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2005, 10:47 AM
Junior Member
 
Join Date: May 2005
Posts: 6
Default Problem in saving XML data in a new file

Hello,

I want to save data in an new file in XML file format. On click of Submit button inside flash I am calling the following function which is inside SwfKit :

Code:
function saveScores()
{
var score = FlashPlayer.getVariable("_level0.gResultXml"); //gResultXml is global variable in flash which contains a huge XML type of string.
// remove the old file
var df = getAppDir() + "scores.xml";
DataFile.remove(df);
DataFile.save(df, "score");
}
It saves the "score.xml" file properly but the problem is I get the following junk characters and additional characters like given below :

[score]
type=string
value=%3Cresponses%3E%3CquestionNo1%3EOption%20B%3 C/questionNo1%3E%3CquestionNo2%3EOption%20D%3C/questionNo2%3E%3C/responses%3E

Actually I should get the output like below(just for example) :

<responses><questionNo1>Option B</questionNo1><questionNo2>Option D</questionNo2></responses>

Why its happening so? Also, I dont want to see [score], type = string value = etc inside the file. Can anyone please guide me regarding above?

Thanks,
Guy Logical
Reply With Quote
  #2 (permalink)  
Old 05-31-2005, 10:57 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Problem in saving XML data in a new file

The DataFile object is used to save the values of swfkit variables in a file which has a special format, you cannot use it to write a xml file.

Please try the following code
Code:
function saveScores()
{
var score = FlashPlayer.getVariable("_level0.gResultXml"); //gResultXml is global variable in flash which contains a huge XML type of string.
// remove the old file
var df = getAppDir() + "scores.xml";
var xmlFile = new FileStream(df, "w");
xmlFile.write(score);
}
Reply With Quote
  #3 (permalink)  
Old 05-31-2005, 11:27 AM
Junior Member
 
Join Date: May 2005
Posts: 6
Default Re:Problem in saving XML data in a new file

Thanks a lot topcmm! That works wonderfully. But here is one more quick query. Currently I am able to save the XML file only on the same directory where Exe file exists. I want to save the XML file to say on C drive. For that I wrote the following code "

Code:
var df = getAppDir() + "C:\\scores.xml";
var xmlFile = new FileStream(df, "w");
xmlFile.write(score);
But when I run the exe file(not from SWFKit's preview but independently from the path where it is actually present) it do not save the "scores.xml" to desired location(on C drive in our case).

Any help on this will be highly appreciated.

Many Thanks,
Guy Logical
Reply With Quote
  #4 (permalink)  
Old 05-31-2005, 11:54 AM
Junior Member
 
Join Date: May 2005
Posts: 6
Default Re:Problem in saving XML data in a new file

Oh Sorry!! What a stupid question I had asked. I should have write :
Code:
var df = "C:\\scores.xml";
instead of
Code:
var df = getAppDir() + "C:\\scores.xml";
Cheers,
Guy Logical
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:56 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.