Hello,
I'm having trouble serilizing different classes to the same xml.
Class #1 is for accounts
Class #2 is for settings
public static void SerializeAcc(List<Account> list)
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Account>), new XmlRootAttribute("Settings"));
using (TextWriter writer = new StreamWriter(XMLPath))
{
serializer.Serialize(writer, list);
}
}
public static void SerializeSett(List<General> list)
{
XmlSerializer serializer = new XmlSerializer(typeof(List<General>), new XmlRootAttribute("Settings"));
using (TextWriter writer = new StreamWriter(XMLPath))
{
serializer.Serialize(writer, list);
}
}
And when I call one it would look like:
<Setting>
<Account>
infohere
</Account>
</Setting>
and when I call the other one instead of putting the info below any account it just replaces it to:
<Setting>
<General>
infohere
</General>
</Setting>
Im trying to accomplish to save both acocunts and settings into the same xml like so:
<Setting>
<Account>
infohere
</Account>
<Account>
infohere
</Account>
<Account>
infohere
</Account>
<General>
infohere
</General>
</Setting>
It can be infinite amount of accounts, but only 1 "General" (Settings) on the bottom.