title: Updating Data in tiny Xml element
body: <p>My question is: is it possible to change the data in an xml element?</p>
  
  <p>What i want to do is change the data in the element depending on what button is pressed. I currently have it reading and writing to the xml file working but i want to change it to, write a new element first time round and then after that edit the element as it currently just keeps writing a new element each time.</p>
  
  <p>This is my current code for writing the new element</p>
  
  <pre><code>if (doc.LoadFile(XMLDOC) == tinyxml2::XML_SUCCESS){
      //Get Root Node
      tinyxml2::XMLElement* rootNode = doc.FirstChildElement();//Assets
      //Get Next Node
      tinyxml2::XMLElement* childNode = rootNode-&gt;FirstChildElement();//imagePaths
      //Temp Element 
      tinyxml2::XMLElement* temp = nullptr;
      tinyxml2::XMLElement* temp2 = childNode-&gt;FirstChildElement();//path
  
      while (temp2 != nullptr){
          temp = temp2;
          temp2 = temp2-&gt;NextSiblingElement("path");
      }
      if (temp != nullptr){
          //write the text
          tinyxml2::XMLComment* newComment = doc.NewComment("Selected Player");
          tinyxml2::XMLElement* newElement = doc.NewElement("path");
  
              //get text passed in 
              newElement-&gt;SetText(choice.c_str());
  
              newElement-&gt;SetAttribute("name", "selected_player");
              childNode-&gt;InsertAfterChild(temp, newComment);
              childNode-&gt;InsertAfterChild(newComment, newElement);
  
      }
      //doc.Print();
      doc.SaveFile(XMLDOC);
      }
      else{
          std::cout &lt;&lt; "Could Not Load XML Document : %s" &lt;&lt; XMLDOC &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>Thanks for helping in advanced </p>