I’m trying to append nodes to an xml file and close the stream at a certain event.
I’ve started with the xmlSettingsExample, but the example saves everything once on key press.
I would like to do something like:
- setup xml (add root note, push tag)
- open file to write xml to
- append xml ‘header’
- while updating append nodes send to a buffer and append to file
- on app exit pop tag, close file
I’ve started like so:
xmlFile.open(ofToDataPath("stream.xml"), ofFile::Append, false);
I imagine on update, after updating my xml I’d do:
xmlFile.writeFromBuffer(xmlBuffer);
and on app exit:
xmlFile.close();
My main question is how do plug my xml object into the xmlBuffer (which is an ofBuffer) ?
I imagine I use the set() method, but not sure how to convert the ofxXmlSettings object to the type accepted by ofBuffer’s set(). Also, is this approach correct or should I be handling this in a different way ?
Thanks!
For the moment I’ve opted for using ofFile to append contents to: