Consider the following code using boost::property_tree:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
using namespace boost::property_tree;
int main() {
ptree model_tree;
model_tree.add("calibrated", "true");
model_tree.add("model.<xmlattr>.label", "label");
model_tree.add("model.activity.<xmlattr>.type", "fixed");
write_xml("test.xml", model_tree);
}
By compiling and executing the program I get the following output:
<?xml version="1.0" encoding="utf-8"?>
<calibrated>true</calibrated><model label="label"><activity type="fixed"/></model>
Which is not really what I expected, as there are no new lines nor indentation. I would like to get the following instead:
<?xml version="1.0" encoding="utf-8"?>
<calibrated>true</calibrated>
<model label="label">
<activity type="fixed"/>
</model>
Is it a bug, or is there an option to obtain the latter output? Any help would be appreciated.
P.S.: I am using Ubuntu 12.04 LTS with gcc 4.6.3 and boost 1.48.