title: Parse XML with boost property tree
body: <p>I have the following XML file and I want to store it using the below structures.</p>
  
  <p>the data structs:</p>
  
  <pre><code>    struct transitions
      {
       string oldstate;
       string event;
       string newstate;
      };
  
      struct XML_Diagram
      {
       string diag_name;
       string diag_defaultstate;
       list&lt;string&gt; diag_states;
       list&lt;string&gt; diag_events;
       list&lt;transitions&gt; diag_transitions;
      };
  </code></pre>
  
  <p>the xml file:</p>
  
  <pre><code>    &lt;diagram&gt;
        &lt;diagname&gt;DiagaX&lt;/diagname&gt;
        &lt;states&gt;
           &lt;state&gt;A&lt;/state&gt;
           .............       
        &lt;/states&gt;
        &lt;events&gt;
            &lt;event&gt;ev1&lt;/event&gt;
            .................
        &lt;/events&gt;
        &lt;defaultstate&gt;A&lt;/defaultstate&gt;
        &lt;transitions&gt;
            &lt;transition&gt;
                &lt;oldstate&gt;A&lt;/oldstate&gt;
                &lt;event&gt;ev1&lt;/event&gt;
                &lt;newstate&gt;B&lt;/newstate&gt;
            &lt;/transition&gt;
            &lt;transition&gt;
                &lt;oldstate&gt;B&lt;/oldstate&gt;
                &lt;event&gt;ev2&lt;/event&gt;
                &lt;newstate&gt;C&lt;/newstate&gt;
            &lt;/transition&gt;
            .........................
        &lt;/transitions&gt;
      &lt;/diagram&gt;
  </code></pre>
  
  <p>It is clear to me how can I to access diagram.states .
  I can do it with the folowing code:</p>
  
  <pre><code>    using boost::property_tree::ptree;
      ptree pt;
  
      // Get diagram states
      BOOST_FOREACH(ptree::value_type &amp;v, pt.get_child("diagram.states"))
      {
         diag_states.push_back(v.second.data());
      }
  </code></pre>
  
  <p>What is not clear to me is how can I access the data from at the level diagram.transitions.transition ?</p>
  
  <p>My problem is that I could not find any examples in the documentation on how to parse more complex xml files with several levels.</p>