TinyXMl文件操作代码编译报错

netcap19820304 netcap19820304 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

一个代码,是修改xml文件中节点属性name的值为1,可是编译报错 请问下该怎么解决呢?

XML修改器.cpp(17): error C2440: “初始化”: 无法从“const wchar_t [14]”转换为“std::basic_string<_Elem,_Traits,_Ax>”
XML修改器.cpp(20): error C2039: “map”: 不是“std”的成员
1>XML修改器.cpp(20): error C2065: “map”: 未声明的标识符
1>XML修改器.cpp(20): error C2275: “std::string”: 将此类型用作表达式非法
1>XML修改器.cpp(20): error C2065: “AttMap”: 未声明的标识符
1>XML修改器.cpp(20): error C2275: “std::string”: 将此类型用作表达式非法
1>XML修改器.cpp(21): error C2065: “AttMap”: 未声明的标识符
1>XML修改器.cpp(21): error C2228: “.insert”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>XML修改器.cpp(22): error C2065: “AttMap”: 未声明的标识符
1>XML修改器.cpp(22): error C3861: “ModifyNode_Attribute”: 找不到标识符


#include "stdafx.h"
#include <iostream>

#include "tinyxml.h"
#include "tinystr.h"
#include <string>
using namespace std;

#pragma comment(lib, "tinyxml_STL.lib")


int _tmain(void)
{
std::string XmlFile = _T("C:\\Demo1.xml");
std::string strNodeName = _T("student");
typedef std::pair <std::string,std::string> String_Pair;
std::map<std::string,std::string> AttMap;
AttMap.insert(String_Pair(_T("name"),_T("1")));
ModifyNode_Attribute(XmlFile,strNodeName,AttMap);

return 0;
}
...全文
评论 6
收藏 已收藏
分享
返回顶部
netcap19820304
VC/MFC 16,550 成员 421,606 内容