Question: 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: 
I would probably try:

```
boost::property_tree::ptree pt;

pt.erase(key);

```
Well, I did it this way:

```
void Backups::removeGeneric(const std::string key, const std::string value)
{
    boost::property_tree::ptree pt;
    boost::property_tree::xml_parser::read_xml(Backups::getBackupFile(), pt);

    bool remove = true;

    try {
        pt.get_child(key);
    }
    catch(boost::exception &ex)
    {  
        std::cout << "There is nothing to remove." << std::endl;
        remove = false;
    }

    if(remove)
    {  
        bool exists = false;

        boost::property_tree::ptree newPt;

        BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child(key))
        {  
            if(v.second.data() != value)
                newPt.add("scheme", v.second.data());

            if(v.second.data() == value)
                exists = true;
        }

        if(exists)
        {  
            pt.put_child(key, newPt);
            boost::property_tree::xml_parser::write_xml(Backups::getBackupFile(), pt);

            std::cout << value << " was removed." << std::endl;
        }
        else
            std::cout << value << " is not added." << std::endl;
    }
}

```