Boost logo

Boost :

Subject: [boost] help with boost::property_tree erasing nested entries please
From: Bernd Prager (bernd_at_[hidden])
Date: 2011-10-03 10:52:05


All,

I would appreciate some help with erasing a nested node entry in
property_tree.
Below is my example. (2) works, but only erases an entire tree. (1)
doesn't but it's really what I want.

Thank you for any help. (I'm sorry, the documentation is not very
verbose on this topic.)

-- Bernd

#include <iostream>
#include <string>

#include <boost/property_tree/ptree.hpp>

using namespace std;
namespace pt = boost::property_tree;

int main(void) {
    pt::ptree props;

    props.put("db.name", "Sesame");
    props.put("user.name", "Ali Baba");
    cout << props.erase("db.name") << " children erased. " << endl;
    // (1)
    cout << props.erase("db")<< " children erased. " << endl; // (2)

}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk