1 | #include <iostream>
|
---|
2 | using namespace std;
|
---|
3 |
|
---|
4 | #include "boost_1_45_0/boost/property_tree/xml_parser.hpp"
|
---|
5 | #include "boost/foreach.hpp"
|
---|
6 | namespace bpt = boost::property_tree;
|
---|
7 |
|
---|
8 | int main() {
|
---|
9 | bpt::ptree pt;
|
---|
10 | try {
|
---|
11 | bpt::read_xml("test.xml", pt, bpt::xml_parser::trim_whitespace
|
---|
12 | || bpt::xml_parser::no_comments);
|
---|
13 | const bpt::ptree::value_type &node = pt.get_child("conf").front();
|
---|
14 | bpt::ptree pt_block = node.second;
|
---|
15 | string name = pt_block.get<string>("name");
|
---|
16 | cout << name << "\n";
|
---|
17 | } catch (bpt::xml_parser_error e) {
|
---|
18 | cout << e.what() << "\n";
|
---|
19 | return 1;
|
---|
20 | }
|
---|
21 | return 0;
|
---|
22 | }
|
---|