title: Parsing SVG (XML) with Boost Property Tree
body: <p>I'm attempting to parse the following SVG (XML) markup with Boost C++'s ptree...</p>
  
  <h2>The SVG (XML)</h2>
  
  <pre><code>&lt;?xml version="1.0" standalone="no"?&gt;
  &lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt;
  &lt;svg height="395.275590551181" version="1.1"
       viewBox="0 0 757.48031496063 395.275590551181" xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink" style="background-color: #ffffff;"&gt;
  &lt;desc&gt;Some Description&lt;/desc&gt;
  &lt;g visibility="hidden" pointer-events="all"&gt;
      &lt;rect x="0" y="0" width="100%" height="100%" fill="none" /&gt;
  &lt;/g&gt;
  &lt;g&gt;
      &lt;path d="M 5 56 L 5 14 L 8 11 L 34 11 Z" /&gt;
      &lt;path d="M 10 100 L 10 140 L 89 131 L 324 2 Z" /&gt;
  &lt;/g&gt;
  &lt;g&gt;
      &lt;path d="M 20 130 L 1 1 L 89 130 L 34 2 Z" /&gt;
  &lt;/g&gt;
  &lt;/svg&gt;
  </code></pre>
  
  <h2>The C++ Code:</h2>
  
  <pre><code>    typedef boost::property_tree::ptree::value_type vt;
      boost::property_tree::ptree root;
      read_xml("My_SVG.svg", root);
      BOOST_FOREACH (vt const &amp;nodes, root.get_child("svg")) {
          //only action on g's and not desc, comments, etc.
          if(nodes.first=="g"){
              boost::property_tree::ptree g = nodes.second;
              //only action on g's that contain paths, not g-&gt;rect, for example.
              if(g.count("path") != 0){
                  BOOST_FOREACH (vt const &amp;p, g.get_child("path")) {
                      std::cout &lt;&lt; p.second.get("d", "false") &lt;&lt; std::endl;
                  }
              }
          }
      }
  </code></pre>
  
  <h2>The Output:</h2>
  
  <pre><code>M 5 56 L 5 14 L 8 11 L 34 11 Z
  M 20 130 L 1 1 L 89 130 L 34 2 Z
  </code></pre>
  
  <h2>The Problem:</h2>
  
  <p>It compiles fine but it's not picking up the <code>M 10 100 L 10 140 L 89 131 L 324 2 Z</code> entry. Why doesn't the second <code>BOOST_FOREACH</code> step through each <code>&lt;path&gt;</code> and <code>cout</code> it.</p>