xmlExample from 0.9.8 to 0.10.0

Hi,

I’m trying to understand the change in code from the older version of OF to the newest one. Specifically how to reproduce the exact steps below in the new version.

Thanks!

// If we have STROKE nodes that we've already created, then we can go ahead and
// load them into the dragPts so they're drawn to the screen
if(XML.exists("STROKE"))
{
    // This gets the first stroke (notice the [0], it's just like an array)
    XML.setTo("STROKE[0]");
    
    
    do {
        // set our "current" PT to the first one
        if(XML.getName() == "STROKE" && XML.setTo("PT[0]"))
        {
            // get each individual x,y for each point
            do {
                int x = XML.getValue<int>("X");
                int y = XML.getValue<int>("Y");
                ofVec2f v(x, y);

                dragPts.push_back(v);
            }
            while(XML.setToSibling()); // go the next PT
            
            // go back up
            XML.setToParent();
        }
        
    }
    while( XML.setToSibling() ); // go to the next STROKE
}

There’s a new version of the example in the input_output folder showing how to use the new ofXml. The section you point out would be:

1 Like