Problem with ofxXmlSettings

I’ve got a bit of a strange one, when I use this code example, similar to the example on http://www.openframeworks.cc/documentation/ofxXmlSettings/ofxXmlSettings.html:

  
	  
	ofxXmlSettings positions;   
	positions.addTag("srcVecs");  
	positions.pushTag("srcVecs");   
	  
	for(int i = 0; i < srcVecs.size(); i++){  
  
		positions.addTag("srcVec");  
		positions.pushTag("srcVec");  
	  
		positions.addValue("X", srcVecs[i].x);  
		positions.addValue("Y", srcVecs[i].y);  
		positions.popTag();  
	  
	}  
	positions.popTag();   
  
  

I get this :

  
<srcVecs>  
    <srcVec>  
        <X>0</X>  
        <Y>0</Y>  
        <X>1024</X>  
        <Y>0</Y>  
        <X>0</X>  
        <Y>768</Y>  
        <X>1024</X>  
        <Y>768</Y>  
    </srcVec>  
    <srcVec></srcVec>  
    <srcVec></srcVec>  
    <srcVec></srcVec>  
</srcVecs>  
  

when I would expect this :

  
<srcVecs>  
    <srcVec>  
        <X>0</X>  
        <Y>0</Y>  
    </srcVec>  
    <srcVec>         
        <X>1024</X>  
        <Y>0</Y>  
    </srcVec>  
    <srcVec>  
        <X>0</X>  
        <Y>768</Y>  
    </srcVec>  
    <srcVec>  
        <X>1024</X>  
        <Y>768</Y>  
    </srcVec>  
</srcVecs>  
  

Have I done something stupid?

Seb

Ah. Seems that the example on the website was missing the which parameter. Code should be :

  
  
  
	ofxXmlSettings positions;   
	positions.addTag("srcVecs");  
	positions.pushTag("srcVecs");   
	  
	for(int i = 0; i < srcVecs.size(); i++){  
  
		positions.addTag("srcVec");  
		positions.pushTag("srcVec", i); // NOTE : requires 'which' parameter.   
	  
		positions.addValue("X", srcVecs[i].x);  
		positions.addValue("Y", srcVecs[i].y);  
		positions.popTag();  
	  
	}  
	positions.popTag();   
  
  

Is that documentation editable? I vaguely remember that it’s on github.

Hey Seb,

Thanks - The site is on github and I opened an issue here:
https://github.com/openframeworks/ofSite/issues/106

thanks Jason!

I am also encountering the same problem as this one… Help Please!

Hi Jak,

I posted the solution in my second post. Does that help you?

Seb