我需要为我的输出创建XML。 我有指标名称的列表。 我想填充它在XML文件中的一种格式。
那是
<response>
<indexes>
<index>abc</index>
<index>xyz</index>
<index>pqr</index>
</indexes>
</response>
我在我的向量索引 - 目录列表。
谁能帮我吗。
我已经尝试了一些代码。 随后
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);
}
当运行上述代码。 IM列表中只得到姓氏。 那是
<response>
<indexes>
<index>pqr</index>
</indexes>
</response>