Can't read stuff from ptree.. please help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Can't read stuff from ptree.. please help

  1. #1
    Join Date
    Dec 2010
    Posts
    597

    Can't read stuff from ptree.. please help

    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>
    Last edited by lucky6969b; February 5th, 2014 at 11:29 PM. Reason: Insufficient Information

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center