XMLDocument xmlDoc;
XMLNode * pRoot = xmlDoc.NewElement("Head");
xmlDoc.InsertFirstChild(pRoot);
XMLElement * pElement = xmlDoc.NewElement("Stat1");
pElement-> SetText(10);
pRoot->InsertEndChild(pElement);
pElement = xmlDoc.NewElement("Stat2");
pElement->SetText(0.5);
pRoot->InsertEndChild(pElement);
XMLNode * pRoot2 = xmlDoc.NewElement("Head2");
xmlDoc.InsertAfterChild(pRoot, pRoot2);
XMLElement * pElement2 = xmlDoc.NewElement("Stat3");
pElement2-> SetText(10);
pRoot2->InsertEndChild(pElement2);
XMLError eResult = xmlDoc.SaveFile("SavedData.xml");
XMLCheckResult(eResult);
The above code will produce an xml file with following xml structure
<Head>
<Stat1>10</Stat1>
<Stat2>0.5</Stat2>
</Head>
<Head2>
<Stat3>10</Stat3>
</Head2>
But i wanted my desire xml structure to be like
<root>
<Head>
<inner-Head>
<Stat1>10</Stat1>
</inner-Head>
<inner-Head2>
<Stat2>0.5</Stat2>
</inner-Head2>
</Head>
<Head2>
<Stat3>10</Stat3>
</Head2>
</root>
I am new to tinyxml2 and could not find any tinyxml2 tutorials,what i wanted to achieve is to have a node inside a node as shown above.