title: Inserting a subtree from text into an existing XML file using tinyxml2
body: <p><strong>I was not allowed to create the new tag 'tinyxml2', that's why I am using the tag 'tinyxml', however I am using 'tinyxml2' !</strong></p>
  
  <p>I am trying to insert a subtree element to an existing XML file. My problem is, that after running the program and checking the XML file the subtree simply does not exist within the document. In the original code I am also checking for errors while loading and saving the file so there is no problem with these functions, they are working correctly. I tried a few different approaches and also adding a single element by using the <code>UserList.NewElement(*name*)</code>-function does also work fine.
  Now I want to insert a whole subtree from a text variable...</p>
  
  <p>My latest approach looks like this (simplified without checking <code>LoadFile</code> and <code>SaveFile</code>):</p>
  
  <pre><code>tinyxml2::XMLDocument UserList;
  UserList.LoadFile(*Path*);
  
  const char* XMLText = "&lt;user name=\"test-user\" gender=\"male\"&gt;&lt;ability description=\"I_can_do_magic\" /&gt;&lt;/user&gt;";
  
  tinyxml2::XMLDocument TestParse;
  TestParse.Parse(XMLText);
  tinyxml2::XMLElement* myNewUser = TestParse.RootElement();
  UserList.FirstChildElement( "magicians" )-&gt;InsertEndChild(myNewUser);
  UserList.SaveFile(*Path*);
  </code></pre>
  
  <p>By the way...
  When I tried to parse my <code>XMLText</code> by using the <code>tinyxml2::XMLDocument UserList</code> the saved XML file will be empty after running the program. This means neither the original XML Document content, nor the newly parsed subtree will be saved when trying to do this. This fact made me use the second <code>tinyxml2::XMLDocument TestParse</code>. Now the XML file is saved containing it's original content, however the parsed subtree is still missing... thank you very much for any solution / help / advice.</p>