title: c++ dom parser problem
body: <p>I want to change an XML file. I'm using DOM Parser. My XML file is the following:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  
  &lt;configuration&gt;
  &lt;property&gt;
    &lt;name&gt;fs.default.name&lt;/name&gt;
    &lt;value&gt; name&lt;/value&gt;
    &lt;/property&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I just want to remove the <code>&lt;value&gt;name&lt;/name&gt;</code> node and put a new node <code>&lt;value&gt;next&lt;/value&gt;</code>. How can I do this?</p>
  
  <p>I wrote code in C++ also, but I'm stuck in the middle. What should I do? My code is the following:</p>
  
  <pre><code>#include&lt;string.h&gt;
  #include&lt;iostream&gt;
  #include&lt;sstream&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;errno.h&gt;
  #include&lt;sys/stat.h&gt;
  #include "parser.hpp"
  using namespace xercesc ;
  using namespace std;
  
  GetConfig::GetConfig()
  {
  XMLPlatformUtils::Initialize();
   TAG_configuration =XMLString::transcode("configuration");
   TAG_property = XMLString::transcode("property");
  TAG_value=XMLString::transcode("value");
  Tag_name=XMLString::transcode("name");
  m_ConfigFileParser=new XercesDOMParser;
  }
  GetConfig::~GetConfig()
  {
   delete m_ConfigFileParser;
  
  XMLString::release( &amp;TAG_configuration );
  XMLString::release( &amp;TAG_property );
  XMLString::release( &amp;TAG_value );
  
  XMLPlatformUtils::Terminate();
  }
  void GetConfig :: readConfigFile(string&amp; configFile)
  {
   struct stat fileStatus;     
  int iretStat = stat(configFile.c_str(), &amp;fileStatus);
     if( iretStat == ENOENT )
            throw ( std::runtime_error("Path file_name does not exist, or path is an empty string.") );
         else if( iretStat == ENOTDIR )
            throw ( std::runtime_error("A component of the path is not a directory."));
         else if( iretStat == ELOOP )
            throw ( std::runtime_error("Too many symbolic links encountered while traversing the path."));
     else if( iretStat == EACCES )
            throw ( std::runtime_error("Permission denied."));
         else if( iretStat == ENAMETOOLONG )
            throw ( std::runtime_error("File can not be read\n"));
  
         // Configure DOM parser.
  
         m_ConfigFileParser-&gt;setValidationScheme( XercesDOMParser::Val_Never );
         m_ConfigFileParser-&gt;setDoNamespaces( false );
         m_ConfigFileParser-&gt;setDoSchema( false );
         m_ConfigFileParser-&gt;setLoadExternalDTD( false );
  
      m_ConfigFileParser-&gt;parse( configFile.c_str() );
  
       DOMDocument* xmlDoc = m_ConfigFileParser-&gt;getDocument();
        DOMElement* elementRoot = xmlDoc-&gt;getDocumentElement();
  
     DOMNodeList*      children = elementRoot-&gt;getChildNodes();
  
  int main()
      {
         string configFile="/home/manish.yadav/Desktop/simple.xml"; 
  
         GetConfig appConfig;
  
     appConfig.readConfigFile(configFile);
  
  
         return 0;
      }
  </code></pre>
  
  <p>Now I don't know how to traverse this document. Here are my questions:</p>
  
  <ul>
  <li>How can I reach to <code>&lt;value&gt;</code>?</li>
  <li>How can I change value of <code>&lt;value&gt; name&lt;/value&gt;</code> to <code>&lt;value&gt; next&lt;/value&gt;</code>?</li>
  </ul>
  
  <p>My idea is to remove the entity and then add it again with different value, but I don't know how to do this, either. Please explain with example code, or suggest any other ideas on how to do this.</p>