ofxXMLSettings pop not working

I think I might have found an error.
When trying to popTag, so you can go to a higher level, there’s a control about this level being higher than 1, otherwise it does not pop.
On pushTag level is updated.

The problem here is level does not seem to get initialized to 0 so it begins at -8900 [i.e]. So once you push level doesn’t get higher than 1 and so you can’t pop

I’ve changed the code here

bool ofxXmlSettings::loadFile(string xmlFile){  
	xmlFile = ofToDataPath(xmlFile);  
	bool loadOkay = doc.LoadFile(xmlFile.c_str());  
	//theo removed bool check as it would  
	//return false if the file exists but was  
	*storedHandle = TiXmlHandle(&doc);  
	return loadOkay;  

And also another problem assuming the initialization is solved. Let’s presume we have an A->B->C structure.
Level 0 is A
push + push
Level 2 is C
Pop [level>1]
Level 1 is B
Pop [level>1] No, so you don’t pop, but you set level to 0
Level 0 is B. We just lost a level

I updated the code here too

int ofxXmlSettings::popTag(){  
	if(level >= 1){  
		TiXmlHandle parent( (storedHandle->ToNode() )->Parent() );  
		*storedHandle = parent;  
		*storedHandle = TiXmlHandle(&doc);  
		level = 0;  
	return level;  

Hope this helps.

wow - thanks for catching those!
both rather amateurish bugs on my part :roll:

updated into svn - see changes here:

people interested can grab changes from svn (copy and paste as one line):

svn co [http://svn.openframeworks.cc/addons/trunk/addons/ofxXmlSettings/](http://svn.openframeworks.cc/addons/trunk/addons/ofxXmlSettings/)    

thanks a lot to you then!

Ohh man I had this bug I could not figure out and it was because of this. Fixed and I’m so excited :slight_smile: