I need to create xml for my output. I have a list of index names. I want to fill it in an XML file in one format.
i.e
<response> <indexes> <index>abc</index> <index>xyz</index> <index>pqr</index> </indexes> </response>
I have a list in my index_list.
Can someone help me.
I tried some code for this. what follows
boost::property_tree::ptree tree; stringstream output; for (std::vector<string>::const_iterator it = index_list.begin(); it != index_list.end(); it++) { std::cout << *it << "\n"; tree.put("response.indexes.index", *it); } if (format == "xml") { write_xml(output, tree); } else { write_json(output, tree); }
When I run the above code. I only get the last name on the list. i.e
<response> <indexes> <index>pqr</index> </indexes> </response>
source share