XML file writting ...

hi all :wink:


Hey Eloi,

Yes you can write new settings with ofXML
just use any one of these:

void setValue(string tag, float valueAsfloat);
void setValue(string tag, int valueAsInt);
void setValue(string tag, string valueAsString);

then followed by:
void saveFile(string xmlFile);

For the tag you can write something that doesn’t exist and it will add it in.


which will make a tag like

          some time here  

Is that what you were after?

totally :wink: i was looking into xmlparser.cpp and found out how to make a new file … but that’s easier :wink: thanks for clearance !!

I have tried adding ofXML to my project in Xcode but get these GLvoid errors in ofGraphics that I don’t know what to do with.

Anyway, I’d like to write a XML file from my project, with statistics from the program more or less. Could someone please explain how to get this to work in more detail? I think I might just have messed up with the references in Xcode…

happy to help you get it setup

GLvoid errors in ofGraphics that I don’t know what to do with.

do you get these w/ every example, or only when you add ofXml ?

you can try this fix from d3:

basically, we have an issue with different versions of gcc on a mac complaining about something… we need to find a way to identify gcc version with xcode. we will fix this for 0.05…

also, you can post a text file or screenshot of the errors – would be helpful


It sounds like you did mess up the references, as the GCC issue is with glu callbacks so I think that is something seperate.

To add ofXML to an existing project you should have the following things.


Please note that this is not the ideal way to add addons to a project - we are working a modular sort of addon system - so this is a bit hacky for now

This folder can be put in your libs or addons folder and from there it can be dragged into the sidebar of xcode - choose ‘relative to project’ from the drop down. http://openframeworks.cc/setup/xcode#quirks-relative

Once it is added - you can use it by adding

#include "ofXML.h"  

to testApp.h or any other classes you have made.

then in your testApp.h
you can put under the other testApp variables:

ofXML xmlSettings;  

and in testApp.cpp - a basic file write example:

xmlSettings.initFromFile(ofToDataPath("settings.xml"), "PARAMS");  
xmlSettings.setValue("APP:VALUE1", 2.03334f); //float value  
xmlSettings.setValue("APP:VALUE2", 2003); //int value  
xmlSettings.setValue("APP:VALUE3", "Hello World"); //string value  

This will save a xml file with the following structure:

               Hello World  

We use the ofToDataPath - to make it save the file relative to openFrameworks’ data/ folder.

Hope that helps - and if not please post which xcode version, openFrameworks version, OS X version you are using and the errors you get!


Great, that works, thanks zach and theo! Both with 0.03 and 0.04 and xcode 2.4.1