当前位置:网站首页>初学XML
初学XML
2022-07-07 10:45:00 【郑7013】
#include"XmlDocument.h"
#include<Windows.h>
std::string toString(const std::wstring str)
{
int len = WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
std::string ret;
if (len <= 0) return ret;
ret.resize(len);
WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, (char*)ret.c_str(), len, NULL, NULL);
return ret;
}
void xmlTest()
{
CoInitialize(NULL); //COM初始化
CXmlDocument doc;
BOOL ret = doc.Load(_T("FaceConfig.xml")); //加载文件
if (!ret)
{
std::cout << "load xml failed!" << std::endl;
}
CXmlNode root;
CXmlNode face;
ret = doc.SelectSingleNode(_T("/faceconfig"), root);
if (ret)
{
std::cout << "row:"<<root.GetAttributeInt(_T("row")) << std::endl;
std::cout << "col:" << root.GetAttributeInt(_T("col")) << std::endl;
std::cout << "item_width:" << root.GetAttributeInt(_T("item_width")) << std::endl;
std::cout << "item_height:" << root.GetAttributeInt(_T("item_height")) << std::endl;
std::cout << "zoom_width:" << root.GetAttributeInt(_T("zoom_width")) << std::endl;
std::cout << "zoom_height:" << root.GetAttributeInt(_T("zoom_height")) << std::endl;
ret = root.GetFirstChildNode(_T("face"),face);
while (ret)
{
std::cout << "[id]:"<< face.GetAttributeInt(_T("id")) << std::endl;
std::cout << "[tip]:"<< toString(face.GetAttribute(_T("tip"))) << std::endl;
std::cout << "[file]:"<< toString(face.GetAttribute(_T("file"))) << std::endl;
ret = face.GetNextSiblingNode(face);
}
}
face.Release();
root.Release();
doc.Release();
CoUninitialize();
}
边栏推荐
- 数据库安全的重要性
- 【从 0 开始学微服务】【03】初探微服务架构
- @Resource和@Autowired的区别?
- 博文推荐|Apache Pulsar 跨地域复制方案选型实践
- NPM instal reports agent or network problems
- Day22 deadlock, thread communication, singleton mode
- 2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
- [Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
- 2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
- MPLS experiment
猜你喜欢
Common knowledge of one-dimensional array and two-dimensional array
基于NeRF的三维内容生成
图形对象的创建与赋值
[statistical learning methods] learning notes - Chapter 5: Decision Tree
2022 polymerization process test question simulation test question bank and online simulation test
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
3D content generation based on nerf
Visual stdio 2017 about the environment configuration of opencv4.1
leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
随机推荐
【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Find ID value MySQL in string
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
leetcode刷题:二叉树23(二叉搜索树中的众数)
有什么类方法或是函数可以查看某个项目的Laravel版本的?
[statistical learning method] learning notes - logistic regression and maximum entropy model
[binary tree] delete points to form a forest
Aike AI frontier promotion (7.7)
HZOJ #240. Graphic printing IV
Image pixel read / write operation
【二叉树】删点成林
What is an esp/msr partition and how to create an esp/msr partition
聊聊Redis缓存4种集群方案、及优缺点对比
[crawler] avoid script detection when using selenium
2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
xshell评估期已过怎么办
MPLS experiment
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘