title: how to create xml using boost property_tree
body: <p>i need to create xml for my output.
  I have a list of index names.
  i want to populate it in an xml file in one format.</p>
  
  <p>that is </p>
  
  <pre><code>&lt;response&gt;
        &lt;indexes&gt;
            &lt;index&gt;abc&lt;/index&gt;
            &lt;index&gt;xyz&lt;/index&gt;
            &lt;index&gt;pqr&lt;/index&gt;
        &lt;/indexes&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>I have the list in my vector index_list.</p>
  
  <p>Can any one help me out.</p>
  
  <p>I have tried some code for that.
  which follows</p>
  
  <pre><code>boost::property_tree::ptree tree;
  stringstream output;
  for (std::vector&lt;string&gt;::const_iterator it = index_list.begin();
          it != index_list.end(); it++) {
      std::cout &lt;&lt; *it &lt;&lt; "\n";
      tree.put("response.indexes.index", *it);
  }
  if (format == "xml") {
      write_xml(output, tree);
  } else {
      write_json(output, tree);
  }
  </code></pre>
  
  <p>When i run the above code . i m getting only last name in the list. that is </p>
  
  <pre><code>&lt;response&gt;
    &lt;indexes&gt;
        &lt;index&gt;pqr&lt;/index&gt;
    &lt;/indexes&gt;
  &lt;/response&gt;
  </code></pre>