【发布时间】:2015-06-26 04:04:27
【问题描述】:
我有一些 C++ 代码来查找 xml 和打印中的差异,使用地图重命名节点标签。这是完整的代码:
#include "pugi/pugixml.hpp"
#include <iostream>
#include <string>
#include <map>
int main()
{
// Define mappings, default left - map on the right
const std::map<std::string, std::string> tagmaps
{
{"id", "id"}, {"description", "content"}
};
pugi::xml_document doca, docb;
pugi::xml_node found, n;
std::map<std::string, pugi::xml_node> mapa, mapb;
if (!doca.load_file("a.xml") || !docb.load_file("b.xml")) {
std::cout << "Can't find input files";
return 1;
}
for (auto& node: doca.child("data").children("entry")) {
const char* id = node.child_value("id");
mapa[id] = node;
}
for (auto& node: docb.child("data").children("entry")) {
const char* idcs = node.child_value("id");
if (!mapa.erase(idcs)) {
mapb[idcs] = node;
}
}
for (auto& ea: mapa) {
std::cout << "Removed:" << std::endl;
ea.second.print(std::cout);
// CURL to remove entries from ES
}
for (auto& eb: mapb) {
// change node name if mapping found
found = tagmaps.find(n.name());
if((found != tagmaps.end()) {
n.set_name(found->second.c_str());
}
}
}
这是我尝试编译时遇到的错误。我是 C++ 新手,我很难修复它。任何帮助或意见将不胜感激。
src/main.cpp:49:8: error: no viable overloaded '='
found = tagmaps.find(n.name());
【问题讨论】: