I have a class and i need to save this class into an XML file. Since i have more objects from this class i need every object to be added under the same root.
I start out with the xml file as this:
<?xml version="1.0" encoding="utf-8"?>
<root>
</root>
My class looks like this:
class Save
{
string a;
string b;
List<subClass> L1;
List<subClass> L2;
subClass
{
string c;
double d;
}
}
The xml file after saveing should look like this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<object>
<Element1>a</Element1>
<Element2>b</Element2>
<objectListL1>
<Element3>c</Element3>
<Element4>d</Element4>
</objectListL1>
...
<objectListL2>
<Element3>c</Element3>
<Element4>d</Element4>
</objectListL2>
...
</object>
</root>
Of course objectListL1 and objectListL2 are repeated as often as entries in the List are found. I just want to create a class, fill it with all my data and than do class.Save() and it should add a new object entry to my XMLfile.