我正在使用 TinyXML2,但遇到了SetAttribute
.
它接受字符串文字(即"001"
)但不接受字符串变量。
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);
}
请在这个问题上赐教。
- customerID 不被接受为字符串,不像“001”被接受且没有错误。但是CustomerID和“001”都是字符串,为什么会这样呢?