当前位置:网站首页>初学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();
}
边栏推荐
- How to apply @transactional transaction annotation to perfection?
- [爬虫]使用selenium时,躲避脚本检测
- 图像像素读写操作
- Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
- Guangzhou held work safety conference
- Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)
- 达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
- 2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
- [statistical learning method] learning notes - support vector machine (Part 2)
- Query whether a field has an index with MySQL
猜你喜欢
BGP third experiment report
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
Day-14 common APIs
Sorting, dichotomy
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)
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
Image pixel read / write operation
Charles: four ways to modify the input parameters or return results of the interface
随机推荐
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
@What is the difference between resource and @autowired?
Object. Simple implementation of assign()
HZOJ #235. Recursive implementation of exponential enumeration
Multi row and multi column flex layout
企业级自定义表单引擎解决方案(十二)--体验代码目录结构
NPM instal reports agent or network problems
图形对象的创建与赋值
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
HZOJ #240. Graphic printing IV
Cookie
Airserver automatically receives multi screen projection or cross device projection
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
[statistical learning method] learning notes - logistic regression and maximum entropy model
Leetcode skimming: binary tree 20 (search in binary search tree)
[deep learning] image multi label classification task, Baidu paddleclas
leetcode刷题:二叉树23(二叉搜索树中的众数)
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
ip2long之后有什么好处?
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst