The following code is used to read the xml file below
<debug>
<filename>debug.log</filename>
<modules>
<module>Finance</module>
<module>Admin</module>
<module>HR</module>
</modules>
<level>2</level>
</debug>
int main()
{
pt::ptree myTree;
pt::read_xml("LogFormat.xml", myTree);
pt::write_xml("RootNode.xml", myTree);
pt::ptree& root = myTree.get_child("debug");
pt::ptree& modulesNode = root.get_child("modules");
pt::write_xml("ModuleNode.xml", modulesNode);
}
RootNode.xml generated was identical to the original source file.
But RootNode.xml only contained the below output
Finance
I expected it to print all the modules as below
<module>Finance</module>
<module>Admin</module>
<module>HR</module>
Can you please explain why write_xml is not consistent when generating the xml for the child node ?
Comments
Post a Comment