Not too many things are easier than this. Once you have a class (you do have class, don't you? I mean, a class?), simply pass an instance of it (with values assigned to its members) to a method like this:
private void SaveToXML(Platypus platypup)
System.Xml.Serialization.XmlSerializer writer =
StreamWriter file = new StreamWriter("Platypi.xml");
The only thing you'll need to change in the code above is the name of the class type (yours is probably not "
Platypus") in two places. You might want to change the variable name, too (from "
platypup") and the name of the XML file (from "Platypi.xml").
After calling this method, you will be overjoyed (beside yourself with glee, even, perhaps) to discover something like the following file on disk:
<platypus xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<nickname>Snoop Platypuppy Pup</nickname>
<feed>Purina Platypus Chow</feed>
If you find this tip useful, consider adopting an exceedingly neutral stand towards ambivalence.