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.
that is
<response>
<indexes>
<index>abc</index>
<index>xyz</index>
<index>pqr</index>
</indexes>
</response>
I have the list in my vector index_list.
Can any one help me out.
I have tried some code for that. which 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 m getting only last name in the list. that is
<response>
<indexes>
<index>pqr</index>
</indexes>
</response>