当前位置:网站首页>Beginner XML
Beginner XML
2022-07-07 13:54:00 【Zheng 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 initialization
CXmlDocument doc;
BOOL ret = doc.Load(_T("FaceConfig.xml")); // Load the file
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();
}
边栏推荐
- Cinnamon taskbar speed
- Mysql怎样控制replace替换的次数?
- 566. Reshaping the matrix
- 室内ROS机器人导航调试记录(膨胀半径的选取经验)
- [QNX hypervisor 2.2 user manual]6.3.4 virtual register (guest_shm.h)
- 参数关键字Final,Flags,Internal,映射关键字Internal
- JS slow motion animation principle teaching (super detail)
- . Net core about redis pipeline and transactions
- Split screen bug notes
- 1、深拷贝 2、call apply bind 3、for of for in 区别
猜你喜欢
Ogre introduction
Use of polarscatter function in MATLAB
Getting started with MySQL
Custom thread pool rejection policy
QQ medicine, Tencent ticket
TPG x AIDU | AI leading talent recruitment plan in progress!
Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
JS slow motion animation principle teaching (super detail)
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
随机推荐
Mysql怎样控制replace替换的次数?
现在网上开户安全么?那么网上开户选哪个证券公司?
Navicat run SQL file import data incomplete or import failed
10 pictures open the door of CPU cache consistency
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
Help tenants
648. Word replacement: the classic application of dictionary tree
[daily training -- Tencent select 50] 231 Power of 2
PHP - laravel cache
Evolution of customer service hotline of dewu
C语言数组相关问题深度理解
"New red flag Cup" desktop application creativity competition 2022
Leecode3. Longest substring without repeated characters
toRaw和markRaw
Cinnamon taskbar speed
带你掌握三层架构(建议收藏)
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
Thread pool reject policy best practices
Show the mathematical formula in El table
华为镜像地址