You have faced the problem of data
persistence. You don't really need to work with XML directly. The best way to persist data in XML is the
Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[
^].
This approach is the easiest to use and most non-intrusive, too. You should have your data in some set of pure-data classes or structures; and you can hold your data in many objects of those types making a graph of any kind, which does not even has to be a tree (it means, if you have circular dependencies quite typical in relational model), it's fine. You simply tell the data contract serialize to store the objects in any file or stream, and later you will be able to restore all these objects at once. You don't need to modify your types in any way (you don't need to inherit certain types, implement certain interface, make anything public, nothing), you only add couple attributes to your types and members. Performance is very good, too, due to automatic generation of serialization assemblies from metadata on the fly, based on
System.Reflection.Emit
.
Please see my past answers where I advocated this approach:
Creating property files...[
^],
How can I utilize XML File streamwriter and reader in my form application?[
^].
—SA