我boost::ptree
用于创建 xml 文件
ptree tree;
ptree & subtree = tree.add("sometag", "");
ptree & subsubtree = tree.add("someothertag", "");
...
write_xml(stfilename, declarationTree, std::locale(),
xml_writer_settings<std::string>(' ', 4));
这将创建以下 XML 文件
<sometag>
<someothertag>
...
</someothertag>
</sometag>
到目前为止一切顺利,但我需要将 xml 属性放入<sometag>
标签中。
而不是这个:
<sometag>
...
我要这个:
<sometag someattribute="somevalue">
...
如何指定属性?boost 文档对此非常不清楚。