help with boost::property_tree erasing nested entries please

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) }

On 03.10.2011 16:52, Bernd Prager wrote:
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.) I'm afraid there is no simple way to do this. There's no path-based erase function. So you can only do this:
props.get("db").erase("name"); Sebastian

Thank you Sebastian. That will do. Sent from my iPhone On Oct 4, 2011, at 5:33 AM, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
On 03.10.2011 16:52, Bernd Prager wrote:
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.) I'm afraid there is no simple way to do this. There's no path-based erase function. So you can only do this:
props.get("db").erase("name");
Sebastian
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Bernd Prager
-
Sebastian Redl