Advertisement
ItachiSan

TinyXML value changer

Oct 9th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include "tinyxml.h"
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main() {
  7.     const char * xmlFileName = "test.xml";
  8.     TiXmlDocument _xmlDoc;
  9.     const char *_currentVersion;
  10.     const char *new_v = "012345";
  11.    
  12.     _xmlDoc.LoadFile(xmlFileName);
  13.    
  14.     TiXmlNode *root = _xmlDoc.FirstChild("GUPInput");
  15.         if (!root)
  16.             {
  17.             printf("It's not a valid GUP input xml.");
  18.             return -1;
  19.             }
  20.            
  21.  
  22.     TiXmlNode *versionNode = root->FirstChildElement("Version");
  23.     if (versionNode)
  24.     {
  25.         TiXmlNode *n = versionNode->FirstChild();
  26.         if (n)
  27.         {
  28.             const char *val = n->Value();
  29.             if (val)
  30.             {
  31.                 _currentVersion = val;
  32.                 printf("Actual version is %s\n", val);
  33.                 n->SetValue(new_v);
  34.                 printf("Actual version should be %s\n", new_v);
  35.             }
  36.            
  37.         }
  38.     }
  39.     _xmlDoc.SaveFile();
  40.     return 0;  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement