I have some C++ code to find the differences in xml and print, using a map to rename the node tags. This is the full code:
#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());
}
}
}
This is the error I get when I try and compile. I'm new to C++ and I'm having a hard time fixing it. Any help or input would be appreciated.
src/main.cpp:49:8: error: no viable overloaded '='
found = tagmaps.find(n.name());