|
|||
|
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");
}
[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 |
|
|||
|
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);
}
|
|
|||
|
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); Any help on this will be highly appreciated. Many Thanks, Guy Logical |
|
|||
|
Oh Sorry!! What a stupid question I had asked. I should have write :
Code:
var df = "C:\\scores.xml"; Code:
var df = getAppDir() + "C:\\scores.xml"; Guy Logical |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|