Strange ofxXmlSettings behaviour

Hi, I’m doing this …

ofLog() << "Creating preset ... ";
presets.addTag("preset");
presets.pushTag("preset");
for (auto &element : ui->elements) {
    if (element->getType() == MY_ELEMENT) {
        
        presets.addTag("element");
        presets.pushTag("element");
        
        presets.addValue("type", element->getSubType());
        presets.addValue("value", element->getValue());

        presets.popTag();
    }
}
presets.popTag();
presets.saveFile("presets.xml");

But I am getting back a structure that looks like this:

<preset>
    <element>
        <type>6</type>
        <type>4</type>
        <type>4</type>
        <type>4</type>
        <type>8</type>
        <value>0</value>
        <type>6</type>
        <type>11</type>
        <type>8</type>
        <value>0</value>
        <type>8</type>
        <value>1</value>
        <type>7</type>
        <value>120.000000000</value>
        <type>7</type>
        <value>3.000000000</value>
        <type>7</type>
        <value>-60.000000000</value>
        <type>7</type>
        <value>20.000000000</value>
        <type>6</type>
        <type>11</type>
        <type>5</type>
        <value>4</value>
        <type>4</type>
        <type>4</type>
        <type>4</type>
        <type>4</type>
        <type>6</type>
        <type>11</type>
        <type>7</type>
        <value>0.000000000</value>
        <type>7</type>
        <value>0.000000000</value>
        <type>7</type>
        <value>1.000000000</value>
        <type>7</type>
        <value>1.000000000</value>
        <type>7</type>
        <value>255.000000000</value>
        <type>7</type>
        <value>255.000000000</value>
        <type>6</type>
        <type>11</type>
        <type>8</type>
        <value>0</value>
        <type>8</type>
        <value>1</value>
        <type>8</type>
        <value>2</value>
    </element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
    <element></element>
</preset>

What am I missing? :sweat:

Ah didn’t notice there was indexing which has to be done. Quite unweildy with arrays !