Hi everyone,
I have run into a few issues involving adding data onto an already existing XML data file.
My current code for making the XML, adding the data and saving it is:
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.events.Event;
stop();
btn_exit.addEventListener(MouseEvent.CLICK, exitConfirm); //IGNORE THIS
btn_submit.addEventListener(MouseEvent.CLICK, submitData); //Submit data event
//IGNORE THIS
function exitConfirm(e:MouseEvent):void {
gotoAndPlay(5);
}
//On "CLICK", Submit data event
function submitData(e:MouseEvent):void {
var file:FileReference = new FileReference;
var app:XML = <app/>;
app.titles = comp_title.text;
app.titles.category = comp_category.text;
app.titles.place = comp_place.text;
app.titles.dateDay = null;
app.titles.dateMonth = null;
app.titles.dateYear = null;
app.titles.gear = null;
file.save(app, "events.xml");
}
My problem is that it only creates this code in the XML file. I have tried adding more code onto this to first find the data on the existing XML then get that and add on the new data, but it doesn't seem to work. I'm not even sure if its possible, so that is why I have come here. Any help is good help!
P.S. AS3 is still fairly new to me. Im not horrible at it, but I aint great either
Cheers!
- Mozza74
read the xml file, store the xml object in an XML variable, edit that variable and finally save it back to the original xml file.