Can I use Linq-to-xml to persist my object state without having to use/know Xpath & XSD Syntax?
ie. really looking for simple but flexible way to persist a graph of object data (e.g. have say 2 or 3 classes with associations) – if Linq-to-xml were as simple as saying “persist this graph to XML”, and then you could also query it via Linq, or load it into memory again/change/then re-save to the xml file.
You don’t usually need XPath or XSD to use LINQ-to-XML, but it also won’t do what you want.
XmlSerializercomes close , but is a tree serializer, not a graph serializer.DataContractSerializer(.NET 3.0) does offer graph support via one of the overloaded constructors, but doesn’t offer full control over the xml.BinaryFormatteroffers graph support and metadata-/type-based workings, but is very brittle if you ever change your assembly, and is not portable between platforms.I suspect the thing to figure out is: is my data a tree or a graph?
XmlSerializermay already do what you need.