Code: Select all
[C] [A] [B]
1 A.XML BrandName
2 A.XML ModelName
3 B.XML
. . .
< /code>
Am Ende des Tages möchte ich Daten in eine Datei schreiben, in der die Header genau oben auf den ihnen entsprechenden Daten stehen. < /p>
Ich weiß, dass es einige geben muss, wenn Anweisungen
Hier ist mein Code ... Danke im Voraus. < /p>
Code: Select all
std::fstream out{"output.csv", std::ios::out};
std::string input_path = "./input/";
// set for headers
std::set headers{
//"/Invoice/cbc:ID",
//"/Invoice/cac:InvoiceLine",
"/Invoice/cac:InvoiceLine/cbc:InvoicedQuantity",
"/Invoice/cac:InvoiceLine/cbc:LineExtensionAmount",
"/Invoice/cac:InvoiceLine/cac:TaxTotal/cbc:TaxAmount",
"/Invoice/cac:InvoiceLine/cac:Item/cbc:Name",
"/Invoice/cac:InvoiceLine/cac:Item/cbc:BrandName",
"/Invoice/cac:InvoiceLine/cac:Item/cbc:ModelName",
};
// vector for map
// test["hello"]["test"][1] = "hello"
using map_t = std::map;
std::vector vectorMap;
// template map
map_t _tmp_map;
// create an instance of pugi xml document
pugi::xml_document doc;
// iterate over filesystem
for (const auto &entry : std::filesystem::directory_iterator(input_path))
{
// check if iterator is a directory, if its continue to next loop
if (std::filesystem::is_directory(entry.path()))
continue;
// load xml file
pugi::xml_parse_result result = doc.load_file(entry.path().c_str());
std::string filename = entry.path().filename().generic_string();
std::cout