XMLSettings Appending instead of overwriting


#1

Hi,

I currently have the following code:

record.setValue("record:beatsPerMinute", byteData);
record.setValue("record:time", ofGetTimestampString());

record.saveFile("recording.xml");

Which returns the following:

151
2018-04-12-18-11-51-967

This is fine, however each time the code is used, it overwrites what is in recording.xml whereas I want it to add to the file so I have a lot of records rather than just one.

Anyone know how I can do this?


#2

Hi,
I think

record.load("recording.xml");
record.addValue("record:beatsPerMinute", byteData);
record.addValue("record:time", ofGetTimestampString());
record.save("recording.xml");

should work.

If you want to do it many times during the application lifetime, it’s probably best to load the xml in the setup() method and to save it in the exit() method.


#3

Worked like a charm, I can’t believe I was only missing that one line!:joy: Thank you very much!