I have a problem. I need to create a following xml:
<?xml version="1.0" encoding="utf-8"?>
<MyApp value="5" name="me">
</MyApp>
Using c++ code I did the following:
#include <iostream>
#include <string>
#include "tinyxml.h"
void main(){
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "utf-8", "");
doc.LinkEndChild( decl );
TiXmlElement * root;
root = new TiXmlElement( "MyApp" );
root->SetAttribute("value","5");
root->SetAttribute("name","me");
doc.LinkEndChild( root );
doc.SaveFile( "madeByHand.xml" );
return 0;
}
I compile it using g++ tinyxml.cpp tinyxmlerror.cpp and tinyxmlparser.cpp. When i want to see the xml i've created. i have an error: it says it's not corectly written. where am i wrong?:)
Just in case anyone will need such a structure of an XML-file:
_
So here is the code for this:
_
_
And an option how to add more then one element using loops (for / while):
_
_
And here is the code for this:
_