boost::property_tree读取解析.xml文件
1)read_xml 支持中文路径
boost::property_tree::wptree wpt;
std::locale::global(std::locale(""));
boost::property_tree::xml_parser::read_xml("E:\测试\test.xml",wpt);
2)get
ptree pt;
read_xml("D://test1.xml",pt); //读入一个xml文件
cout<<"ID is "<<pt.get<int>("con.id")<<endl;//读取节点中的信息
3)get_child
child = pt.get_child("con.urls");
for(BOOST_AUTO(pos,child.begin());pos != child.end();++pos) //boost中的auto
{
cout<<" "+pos->second.data()<<endl;
}
4)put
pt.put("con.name","Sword"); //更改某个键值
5)add
pt.add("con.id","3"); //增加某个键值
6)write_xml
write_xml("D://test1.xml",pt); //写入XML