· 6 years ago · Jun 15, 2019, 04:42 PM
1<Parameters>
2 <Parameter ParameterName="AccessKey" ParameterValue="ABC"/>
3 <Parameter ParameterName="SecretKey" ParameterValue="XYZ"/>
4</Parameters>
5
6<Parameters>
7 <AccessKey>ABC</AccessKey>
8 <SecretKey>XYZ</SecretKey>
9</Parameters>
10
11#include <boost/property_tree/ptree.hpp>
12#include <boost/property_tree/xml_parser.hpp>
13namespace pt = boost::property_tree;
14
15bool getCredentialsfromXml(const std::string &xmlFileName, Credentials& credentials)
16{
17 pt::ptree tree;
18 pt::read_xml(xmlFileName, tree);
19
20 // 1. AccessKey
21 credentials.m_accessKey = tree.get_optional<std::string>("Parameters.AccessKey");
22
23 // 2. SecretKey
24 credentials.m_secretKey = tree.get_optional<std::string>("Parameters.SecretKey");
25
26 return true;
27}