create a c++ sepa.xml pain 008.001.08 tool, no comment, but be aware of BIC isn“t correct. You replace BIC with BICFI. This tool must allow, to import hundrets of creditors, but be aware, no fixed sums. Sums will be added <|channel|>analysis<|message|>Need compute sum amounts from input and set total. Provide amount per creditor. Use csv with amount field. Compute CtrlSum. No comments.<|end|> <|start|>assistant<|channel|>final<|message|>```cpp #include #include #include #include #include "tinyxml2.h" using namespace tinyxml2; struct Creditor{ std::string name, iban, bicfi; double amt; }; static XMLElement* textElement(XMLDocument& d,const char*s,const char*t){auto e=d.NewElement(s);e->SetText(t);return e;} static std::vector load(const std::string& fn){ std::ifstream f(fn); std::string l,n,i,b; double a; std::vector r; while(std::getline(f,l)){ std::istringstream s(l); if(!std::getline(s,n,';'))continue; if(!std::getline(s,i,';'))continue; if(!std::getline(s,b,';'))continue; if(!(s>>a))continue; r.push_back({n,i,b,a}); } return r; } int main(int ac,char**av){ std::string csv=(ac>1)?av[1]:"creditors.csv"; auto cr=load(csv); double total=0; for(auto&c:cr)total+=c.amt; XMLDocument d; auto doc=d.NewElement("Document"); doc->SetAttribute("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.008.001.08"); d.InsertFirstChild(doc); auto init=d.NewElement("CstmrCdtTrfInitn"); doc->InsertEndChild(init); auto hdr=d.NewElement("GrpHdr"); init->InsertEndChild(hdr); hdr->InsertEndChild(textElement(d,"MsgId","MSG001")); hdr->InsertEndChild(textElement(d,"CreDtTm","2025-08-26T12:00:00+02:00")); hdr->InsertEndChild(textElement(d,"NbOfTxs",std::to_string(cr.size()).c_str())); hdr->InsertEndChild(textElement(d,"CtrlSum",std::to_string(total).c_str())); auto pmt=d.NewElement("PmtInf"); init->InsertEndChild(pmt); pmt->InsertEndChild(textElement(d,"PmtInfId","PMTINF001")); pmt->InsertEndChild(textElement(d,"PmtMtd","TRF")); pmt->InsertEndChild(textElement(d,"NbOfTxs",std::to_string(cr.size()).c_str())); pmt->InsertEndChild(textElement(d,"CtrlSum",std::to_string(total).c_str())); auto tp=d.NewElement("PmtTpInf"); pmt->InsertEndChild(tp); tp->InsertEndChild(textElement(d,"SvcLvl","SEPA")); tp->InsertEndChild(textElement(d,"LclInstrm","CORE")); tp->InsertEndChild(textElement(d,"SeqTp","FRST")); for(const auto&c:cr){ auto tx=d.NewElement("CdtTrfTxInf"); pmt->InsertEndChild(tx); tx->InsertEndChild(textElement(d,"PmtId",c.name.c_str())); tx->InsertEndChild(textElement(d,"Amt",std::to_string(c.amt).c_str())); auto ca=d.NewElement("CdtrAgt"); auto fi=d.NewElement("FinInstnId"); fi->InsertEndChild(textElement(d,"BICFI",c.bicfi.c_str())); ca->InsertEndChild(fi); tx->InsertEndChild(ca); auto cd=d.NewElement("Cdtr"); cd->InsertEndChild(textElement(d,"Nm",c.name.c_str())); tx->InsertEndChild(cd); auto acct=d.NewElement("CdtrAcct"); auto id=d.NewElement("Id"); id->InsertEndChild(textElement(d,"IBAN",c.iban.c_str())); acct->InsertEndChild(id); tx->InsertEndChild(acct); } d.SaveFile("sepa_payment.xml"); } ```