title: How to remove a node of a YAML document with yaml-cpp
body: <p>I have a YAML file like:</p>
  
  <pre><code>top:
    names:
      - name: john1
      - name: john2
      - name: john3
      - name: john.doe
  </code></pre>
  
  <p>Now I have to remove top/names/name(john.doe). How can I achieve that with yaml-cpp? My code is:</p>
  
  <pre><code>void deleteNode(string id)
  {
      YAML::Node config = YAML::LoadFile("doc.yaml");
      for (int i = 0; i &lt; config["top"]["names"].size(); i++)
      {
          if(config["top"]["names"][i]["name"].as&lt;string&gt;() == id)
          {
              config["top"]["names"].remove(config["top"]["names"][i]);
              break;
          }
      }
  }
  deleteNode("john.doe");
  </code></pre>
  
  <p>This doesn't seem to do anything.</p>