title: RapidXML, reading and saving values
body: <p>I've worked myself through the rapidXML sources and managed to read some values. Now I want to change them and save them to my XML file:</p>
  
  <p>Parsing file and set a pointer</p>
  
  <pre><code>void SettingsHandler::getConfigFile() {
      pcSourceConfig = parsing-&gt;readFileInChar(CONF);
  
      cfg.parse&lt;0&gt;(pcSourceConfig);
  }
  </code></pre>
  
  <p>Reading values from XML</p>
  
  <pre><code>void SettingsHandler::getDefinitions() {    
      SettingsHandler::getConfigFile();
      stGeneral = cfg.first_node("settings")-&gt;value();
      /* stGeneral = 60 */
  }
  </code></pre>
  
  <p>Changing values and saving to file</p>
  
  <pre><code>void SettingsHandler::setDefinitions() {
      SettingsHandler::getConfigFile();
  
      stGeneral = "10";
  
      cfg.first_node("settings")-&gt;value(stGeneral.c_str());
  
      std::stringstream sStream;
      sStream &lt;&lt; *cfg.first_node();
  
      std::ofstream ofFileToWrite;
      ofFileToWrite.open(CONF, std::ios::trunc);
      ofFileToWrite &lt;&lt; "&lt;?xml version=\"1.0\"?&gt;\n" &lt;&lt; sStream.str() &lt;&lt; '\0';
      ofFileToWrite.close();
  }
  </code></pre>
  
  <p>Reading file into buffer</p>
  
  <pre><code>char* Parser::readFileInChar(const char* p_pccFile) {
      char* cpBuffer;
      size_t sSize;
  
      std::ifstream ifFileToRead;
      ifFileToRead.open(p_pccFile, std::ios::binary);
      sSize = Parser::getFileLength(&amp;ifFileToRead);
      cpBuffer = new char[sSize];
      ifFileToRead.read( cpBuffer, sSize);
      ifFileToRead.close();
  
      return cpBuffer;
  }
  </code></pre>
  
  <p>However, it's not possible to save the new value. My code is just saving the original file with a value of "60" where it should be "10".</p>
  
  <p>Rgds
  Layne</p>