Boost property tree: Remove a node

Rasmus Styrk picture Rasmus Styrk · Jun 15, 2012 · Viewed 10.7k times · Source

How would you remove a node from boost xml property tree?

I have a document like this:

<folders>
  <folder>some/folder</folder>
  <folder>some/folder</folder>
  <folder>some/folder</folder>
</folders>

I know how to itereate and print all folders, but how would i remove one of the items and save the xml back?

Answer

yosoy89 picture yosoy89 · Apr 1, 2013

I would probably try:

boost::property_tree::ptree pt;

pt.erase(key);