XML writing using XmlDocument in .net c++

mikemelon

New Member
i'm trying to write config of my program in exe looking like that:\[code\]<test> <a1> <b>100</b> <c>2</c> <d>0</d> </a1> <a2> <b>100</b> <c>2</c> <d>0</d> </a2></test><test2><!-- ...--></test2>\[/code\]I'm trying to do that with this code:\[code\] XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<a1></a1"); XmlElement^ newElem = doc->CreateElement( "value" ); newElem->InnerText = "105"; doc->DocumentElement->AppendChild( newElem ); newElem = doc->CreateElement( "hotkey" ); newElem->InnerText = "2"; doc->DocumentElement->AppendChild( newElem ); newElem = doc->CreateElement( "enable" ); newElem->InnerText = "0"; doc->DocumentElement->AppendChild( newElem ); doc->LoadXml( "<a2></a2>"); newElem = doc->CreateElement( "value" ); newElem->InnerText = "105"; doc->DocumentElement->AppendChild( newElem ); newElem = doc->CreateElement( "hotkey" ); newElem->InnerText = "2"; doc->DocumentElement->AppendChild( newElem ); newElem = doc->CreateElement( "enable" ); newElem->InnerText = "0"; doc->DocumentElement->AppendChild( newElem );\[/code\]but second loadXml overvrite first, and i don't know how to do more categorys. Can somebody help me with them?
 
Back
Top