title: Boost C++ XML parsing
body: <p>I am slightly familiar on how to parse XML with boost, if the XML has up to and including 3 levels. However, I am having trouble with the following example:</p>
  
  <p>(Please ignore the slight lack of logic in the XML since this is an adaptation of something I cannot change. The structure is important)</p>
  
  <pre><code>&lt;content&gt;
  
        &lt;Room&gt;
             &lt;RoomName&gt;Livingroom&lt;/RoomName&gt;             
              &lt;Description&gt; 
                   &lt;Color&gt;Red&lt;/Color&gt;
                   &lt;Size&gt;Small&lt;/Size&gt;                   
              &lt;/Description&gt;
              &lt;Description&gt;
                   &lt;Color&gt;Blue&lt;/Color&gt;
                   &lt;Size&gt;Big&lt;/Size&gt;                         
              &lt;/Description&gt;         
        &lt;/Room&gt;
  
        &lt;Room&gt;
             &lt;RoomName&gt;Bathroom&lt;/RoomName&gt;
              &lt;Description&gt;
                  &lt;Color&gt;Green&lt;/Color&gt;
                  &lt;Size&gt;Medium&lt;/Size&gt;
              &lt;/Description&gt;
        &lt;/Room&gt;  
  
  &lt;/content&gt;
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>struct Room
  {
      std::string roomName;
      std::string  roomColor;
      std::string  roomSize;   
  };
  
  void parseRoomsXml(){
  
      boost::property_tree::ptree tree;
      boost::property_tree::read_xml("./Rooms.xml", tree);
      boost::property_tree::ptree formats = tree.get_child("content");
  
      BOOST_FOREACH( boost::property_tree::ptree::value_type const&amp; f, formats ) {
          if( f.first == "Room" ) {
              Room s;
              s.roomName = f.second.get&lt;std::string&gt;("RoomName");
              std::cout&lt;&lt;s.roomName&lt;&lt;std::endl;
  
              const boost::property_tree::ptree &amp; attributes = formats.get_child("Room");
  
              BOOST_FOREACH( boost::property_tree::ptree::value_type const&amp; v, attributes ) {
                  if (v.first == "Description"){
                      s.roomColor = v.second.get&lt;std::string&gt;("Color");
                      s.roomSize = v.second.get&lt;std::string&gt;("Size");
                      std::cout&lt;&lt; s.roomColor &lt;&lt; " " &lt;&lt;s.roomSize;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>The Result is that the first room is parsed correctly, but the second room has the Description of the first one:</p>
  
  <p>=========================</p>
  
  <p>Output:</p>
  
  <p>Livingroom</p>
  
  <p>Red   Small</p>
  
  <p>Blue  Big</p>
  
  <p>Bathroom</p>
  
  <p>Red   Small</p>
  
  <p>Blue  Big</p>
  
  <p>========================</p>
  
  <p>Expected result would be:</p>
  
  <p>Livingroom</p>
  
  <p>Red   Small</p>
  
  <p>Blue  Big</p>
  
  <p>Bathroom</p>
  
  <p>Green Medium</p>
  
  <p>===================================</p>
  
  <p>Thanks in advance, any help would be appreciated, since I am trying to get used to boost.</p>