title: RapidXML / C++ - parsing into a static class member
body: <p>I have a class with a rapidxml::xml_document, but when I try to parse XML into it, it populates with... well, not garbage, but information about my namespaces and the like.</p>
  
  <p>In the code below I have examples of what I've tried, commented out, and a local variable, doc being properly populated from the class member string.</p>
  
  <p>Any ideas?</p>
  
  <p>.h</p>
  
  <pre><code>class PrintHeadGeometry
  {
      // XML Stuff
      static rapidxml::xml_document&lt;&gt; m_xmlDocDPHX;   
      static std::string m_xmlStringDPHX;  
  
      // etc
  };
  </code></pre>
  
  <p>.cpp</p>
  
  <pre><code>// near the top
  rapidxml::xml_document&lt;&gt; PrintHeadGeometry::m_xmlDocDPHX;
  std::string PrintHeadGeometry::m_xmlStringDPHX = "";
  
  // in my "load" function
  std::ifstream file(filename);
  std::stringstream buffer;
  buffer &lt;&lt; file.rdbuf();
  file.close();
  std::string content(buffer.str());
  m_xmlStringDPHX = content;
  
  // NEITHER OF THESE WORK - I WANTED THE TOP ONE, IDEALLY
  //
  //m_xmlDocDPHX.parse&lt;0&gt;(&amp;m_xmlStringDPHX[0]);
  //m_xmlDocDPHX.parse&lt;0&gt;(&amp;content[0]);
  
  // THIS WORKS THOUGH
  //
  rapidxml::xml_document&lt;&gt; doc;
  doc.parse&lt;0&gt;(&amp;m_xmlStringDPHX[0]);
  </code></pre>