不能在 setAttribute 中传递字符串

Can not pass string in setAttribute

本文关键字:字符串 setAttribute 不能      更新时间:2023-10-16
TiXmlElement * book = new TiXmlElement( "book" );  
    root->LinkEndChild( book );  
    string str1="name";
    const string str2=catalog[i].id();
    book->SetAttribute(str1,str2);

我收到这样的错误[错误] 调用 'TiXmlElement::SetAttribute(std::string&, const string&(' 时没有匹配函数

无论如何,我需要设置该属性。

你忘了#define TIXML_USE_STL吗?