How do I SAVE/ UPDATE xml in Construct 2?

0 favourites
  • 7 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello,

    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.

    Regards,

  • You may want to read THIS

    ~Sol

  • 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.

    ~Sol

  • Can the Construct 2 Genius Ashley able to help this?

  • The xml plugin only reads xml, it doesn't write.

    To write you'll need to either make your own writer or try to utilize some javascript library to do it.

    You can look here for the xml file format:

    https://en.wikipedia.org/wiki/XML

    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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)