title: Iterating over variables within an XML file using Boost Property Tree
body: <p>Could anyone help me with iterating over the variables within the XML file I've got, using boost property tree?</p>
  
  <pre><code>&lt;HLSL&gt;
    &lt;Constants&gt;
      &lt;Constant name ="myObject"&gt;
        &lt;Variable name ="matWorld" class ="matrix" type="float" rows="4" cols="4"/&gt;
        &lt;Variable name ="vObjectPosition" class ="vector" type="float" rows="1" cols="3"/&gt;
        &lt;Variable name ="arrayIndex" class ="scalar" type="int" rows="0" cols="0"/&gt;
      &lt;/Constant&gt;
    &lt;/Constants&gt;
  &lt;/HLSL&gt;
  </code></pre>
  
  <p>Here's my code so far [ it won't go past the first variable within the XML ]</p>
  
  <pre><code>void CFxCompiler::LoadShader(const string&amp; headerName, const string&amp; asmName)
  {
      using std::vector;
  
      // Create an empty property tree object
      iptree pt;
  
      // Load the XML file into the property tree. If reading fails
      // (cannot open file, parse error), an exception is thrown.
      read_xml(headerName, pt);
  
      iptree &amp;itorLevel = pt.get_child("HLSL");
      iptree &amp;constLevel = itorLevel.get_child("Constants");
      BOOST_FOREACH(iptree::value_type&amp; constant, constLevel.get_child("Constant"))
      {   
          BOOST_FOREACH(iptree::value_type&amp; constAttrib, constLevel.get_child("Constant.&lt;xmlattr&gt;"))
          {
              std::string bufferName = constAttrib.second.get&lt;std::string&gt;("");
              CConstantFormatPtr pConstFormat = make_shared&lt;CConstantFormat&gt;(bufferName, 0);
  
              // Populate the variables
              iptree &amp;varLevel = constLevel.get_child("Constant.Variable");
              BOOST_FOREACH(iptree::value_type&amp; variable, varLevel.get_child("") )
              {
                  std::string attribute = variable.first;
                  BOOST_FOREACH(iptree::value_type&amp; variableAttrib, varLevel.get_child( attribute.c_str() ))
                  {
                      //CConstantElementDesc desc = BuildConstantVariable(variableAttrib);
                      int pause = 1;
                  }
              }
  
          }
       }
  </code></pre>