Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofXml setAttribute produces anonymous tag

$
0
0

@hamoid wrote:

Hi! This code:

void ofxPolySave(const ofPolyline & poly, string xmlPath) {
    ofXml xml;
    auto data = xml.appendChild("poly");
    //data.setAttribute("closed", ofToString(poly.isClosed()));
    for(auto & point : poly.getVertices()) {
        auto p = data.appendChild("point");
        p.setAttribute("x", ofToString(point.x));
        p.setAttribute("y", ofToString(point.y));
    }
    data.setAttribute("closed", ofToString(poly.isClosed()));
    xml.save(xmlPath);
}

produces this file:

<?xml version="1.0"?>
<poly>
        <point x="226" y="483" />
        <point x="378" y="420" />
        <point x="508" y="494" />
        <point x="442" y="565" />
</poly>
<:anonymous closed="0" />

?
Note the <:anonymous /> tag at the end.

If I move the .setAttribute line up before the for loop, all the point tags go inside the anonymous tag. Different error, but no better.

I can't find anything about anonymity in xml :stuck_out_tongue: nor the word anonymous in the whole source of openframeworks.

Any ideas?

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images