当前位置:网站首页>初学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();
}
边栏推荐
- Preorder, inorder and postorder traversal of binary tree
- Common knowledge of one-dimensional array and two-dimensional array
- 【从 0 开始学微服务】【01】什么是微服务
- 2022聚合工艺考试题模拟考试题库及在线模拟考试
- 在字符串中查找id值MySQL
- Day-18 hash table, generic
- Realize a simple version of array by yourself from
- 处理链中断后如何继续/子链出错removed from scheduling
- HZOJ #235. Recursive implementation of exponential enumeration
- [statistical learning method] learning notes - logistic regression and maximum entropy model
猜你喜欢
Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
[statistical learning method] learning notes - logistic regression and maximum entropy model
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
Polymorphism, final, etc
NPM instal reports agent or network problems
如何将 @Transactional 事务注解运用到炉火纯青?
图形对象的创建与赋值
HZOJ #240. Graphic printing IV
JS to convert array to tree data
Several ways to clear floating
随机推荐
Master公式。(用于计算递归的时间复杂度。)
【PyTorch实战】用RNN写诗
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
@Resource和@Autowired的区别?
Sorting, dichotomy
Aike AI frontier promotion (7.7)
3D content generation based on nerf
On valuation model (II): PE index II - PE band
[statistical learning methods] learning notes - improvement methods
Realize all, race, allsettled and any of the simple version of promise by yourself
mysql怎么创建,删除,查看索引?
Multi row and multi column flex layout
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
Image pixel read / write operation
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
[binary tree] delete points to form a forest
visual stdio 2017关于opencv4.1的环境配置
ICLR 2022 | pre training language model based on anti self attention mechanism
leetcode刷题:二叉树19(合并二叉树)