当前位置:网站首页>初学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();
}边栏推荐
猜你喜欢

On valuation model (II): PE index II - PE band

leetcode刷题:二叉树27(删除二叉搜索树中的节点)

Day22 deadlock, thread communication, singleton mode

Charles: four ways to modify the input parameters or return results of the interface

Day-18 hash table, generic

达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑

Creation and assignment of graphic objects
![[statistical learning method] learning notes - support vector machine (I)](/img/3f/56db88d717d7cd6624b3d0867146e9.png)
[statistical learning method] learning notes - support vector machine (I)

Session

Preorder, inorder and postorder traversal of binary tree
随机推荐
PHP calls the pure IP database to return the specific address
Cookie
MPLS experiment
[learn microservice from 0] [01] what is microservice
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
MySQL importing SQL files and common commands
Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)
JS to convert array to tree data
【统计学习方法】学习笔记——第五章:决策树
PHP调用纯真IP数据库返回具体地址
广州市召开安全生产工作会议
What if does not match your user account appears when submitting the code?
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Static vxlan configuration
mysql怎么创建,删除,查看索引?
Image pixel read / write operation
如何将 @Transactional 事务注解运用到炉火纯青?
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
Design and implementation of communication protocol
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘