当前位置:网站首页>初学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();
}边栏推荐
- leetcode刷题:二叉树26(二叉搜索树中的插入操作)
- [learn microservices from 0] [03] explore the microservice architecture
- Image pixel read / write operation
- 【从 0 开始学微服务】【03】初探微服务架构
- Creation and assignment of graphic objects
- 高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作
- Find ID value MySQL in string
- 聊聊Redis缓存4种集群方案、及优缺点对比
- 详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
- The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
猜你喜欢

2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
![[statistical learning methods] learning notes - improvement methods](/img/c5/515f171995da8e424de290228b54f8.png)
[statistical learning methods] learning notes - improvement methods

Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)

高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作

Leetcode skimming: binary tree 20 (search in binary search tree)

Static vxlan configuration

JS to convert array to tree data
![《ASP.NET Core 6框架揭秘》样章[200页/5章]](/img/4f/5688c391dd19129d912a3557732047.jpg)
《ASP.NET Core 6框架揭秘》样章[200页/5章]

博文推荐|Apache Pulsar 跨地域复制方案选型实践

NPM instal reports agent or network problems
随机推荐
HZOJ #240. 图形打印四
Preorder, inorder and postorder traversal of binary tree
The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
Several ways to clear floating
图形对象的创建与赋值
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
《ASP.NET Core 6框架揭秘》样章[200页/5章]
图像像素读写操作
HZOJ #235. 递归实现指数型枚举
Design and implementation of communication protocol
BGP actual network configuration
Day21 multithreading
Vxlan static centralized gateway
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
Simple implementation of call, bind and apply
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
【统计学习方法】学习笔记——第四章:朴素贝叶斯法
[爬虫]使用selenium时,躲避脚本检测
Session