Can't read the attribute from the ptree object. Any ideas how to do that?
Thanks
Jack
Code:
BOOST_FOREACH(ptree::value_type& v, tree) {
const std::string& nodeName = v.first;
simData.FrameName = readString(v, "Name");
simData.relative = readMatrix(v, "relative");
simData.obj = readMatrix(v, "object");
BOOST_FOREACH(ptree::value_type& v2,
tree.get_child("FrameName.Mesh")) {
simData.MeshName = readString(v2, "<xmlattr>.name"); << throws here
simData.NumVertices = readInt(v2, "NumVertices");
Code:
std::string readString(const ptree::value_type& tree, std::string location)
{
std::string str = tree.second.get<std::string>(location.c_str());
return str;
}
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameName>
<Name>Box001</Name>
<relative>
<matrix>
<00>1</00>
<01>0</01>
<02>0</02>
<03>0</03>
<10>0</10>
<11>1</11>
<12>0</12>
<13>0</13>
<20>0</20>
<21>0</21>
<22>1</22>
<23>0</23>
<30>2.376553</30>
<31>0</31>
<32>20.12135</32>
<33>1</33>
</matrix>
</relative>
<object>
<matrix>
<00>1</00>
<01>0</01>
<02>0</02>
<03>0</03>
<10>0</10>
<11>1</11>
<12>0</12>
<13>0</13>
<20>0</20>
<21>0</21>
<22>1</22>
<23>0</23>
<30>0</30>
<31>0</31>
<32>0</32>
<33>1</33>
</matrix>
</object>
<Mesh name="Mesh_Box001">
<NumVertices>24</NumVertices>
<Vertices>
<vector index="0">
<x>-30.889</x>
<y>0</y>
<z>-36.3461</z>
</vector>
</Vertices>