그냥 insert
사용
ptree pt;
pt.add("a.c.d", "hello");
pt.add("a.e", "world");
pt.add("a.b", "bye");
write_xml(std::cout, pt, boost::property_tree::xml_writer_make_settings<std::string>(' ', 2));
인쇄
<?xml version="1.0" encoding="utf-8"?>
<a>
<c>
<d>hello</d>
</c>
<e>world</e>
<b>bye</b>
</a>
를 특정 위치에 노드를 삽입 insert
사용 :
// let's move `b` to the start:
ptree pt;
pt.add("a.c.d", "hello");
pt.add("a.e", "world");
auto& a = pt.get_child("a");
a.insert(a.begin(), {"b", ptree{"bye"}});
write_xml(std::cout, pt, boost::property_tree::xml_writer_make_settings<std::string>(' ', 2));
인쇄
<?xml version="1.0" encoding="utf-8"?>
<a>
<b>bye</b>
<c>
<d>hello</d>
</c>
<e>world</e>
</a>
감사합니다. 정확하게 필요한 것입니다. – user7431005