C# and XML

That.. doesn't help. I searched StackOverflow before I asked here. :/

Mainly because I'm not entirely sure how I'm going to get the following sequence
> Main program reads the saved file, and passes the contents off to the library/object to parse.

I'm reasonably sure this involves a XMLReader, but it reads *streams*
 
I would use XDocument (not XMLDocument). YMMV but I've found it to be easy to use.
 
I'm trying to think of a good way to save/load. But I can't think of any real way to pass the XML from the program reading it to the library that interprets it. I'd rather NOT use XMLDocument but if people think I should, I would.

Does this document represent a class? If so, you might be able to get away with XmlSerializer to serialize, deserialize to disk.
 
I tried that, and I am not very willing to write interfaces to serialize it (the class has lists under it, as well as private members)

And since the private members are there because I need to sanity check people (no putting Tiny Gas Giant Garden worlds, for example) I don't want to make them public..
 
I don't know if this is any help, but I wrote a simple C# program a while back that loads an xml file, makes some changes, and saves the new XML.
 

Attachments

There is a much faster way to get from XML in to unattached DataTable objects (these work just like SQL Tables, including indexing).

Define your various DataTables. Place the DataTable objects into a single DataSet Object. Use the DataSet's WriteXML and ReadXML methods to save to and load form a file on disk. This has the advantage of being faster then the LINQ to XML methods, but it's collections are slower then the DataEntities Framework. If you can, I'd look at a DataEntities framework solution for working with XML data.
 

Back
Top Bottom