I'm using TinyXML2 and I'm facing an issue with SetAttribute
.
It accepts a string literal (i.e. "001"
) but not a string variable.
void createDoc(string customerID, string name) {
XMLDocument doc;
XMLNode * pRoot = doc.NewElement("containerRequirement");
doc.InsertFirstChild(pRoot);
XMLElement * p1Element = doc.NewElement("customer"); // Start customer
p1Element->SetAttribute("ID", customerID); // not working
p1Element->SetAttribute("ID", "001"); // working
XMLElement * p2Element = doc.NewElement("name");
cout << "NAME is: " << name << endl;
p2Element->SetText(name);
}
Please enlighten me on this issue.
- customerID is not accepted as a String unlike "001" is accepted with no errors. But both CustomerID and "001" are strings, why does this happen?