What is the best way to append data into XML in Construct 2 and Load it back?
My Construct 2 application will generate XML file daily based on user inputs and user will be able to load the xml data.
It is simply READ and WRITE method.
Thanks for any information.
You may want to read THIS
Develop games in your browser. Powerful, performant & highly capable.
Thanks Sol. I need an example within Construct 2.
Sadly I've never worked directly with XML in C2 so a manual reference was all I had, sorry. Maybe someone else will have more info.
Can the Construct 2 Genius Ashley able to help this?
The xml plugin only reads xml, it doesn't write.
You can look here for the xml file format:
So basically the best way to append data to an xml file is to load it with ajax or with nwjs, store it in a variable, then just add text to the end.
As an example, if you have a file called "animal.xml" added to your project you can load it, append data to it, and finally download it with this:
start of layout
--- ajax: request animal.xml
global text xml=""
ajax: on loaded
--- set xml to ajax.lastdata
--- add "<fish>tuna</fish>" to xml
--- browser: invoke download of xml
You have to use server side code to write XML (or any) file. Only server side code contained in a secure environment is adequately trusted to have write privileges on a computer.
If you don't mind asking the user to save the XML, you can do what R0j0 suggests with the file download invoker.