Monday, July 05, 2004

Really quite useful...

... I'm guessing that's why they built it.

I'm talking about the System.XML.XMLDatadocument class. I'm really quite liking using this.

In my new little blogging app, I want to have all the actual content saved as XML (several reasons, not least of which because I haven't had a chance to really use XMLfor much yet). However, I also didn't want to spend days writing UI code that pulled the XML file apart and bound that data to the form.

Enter the XMLDataDocument. It's got all the usual XML stuff, Node collection, Load method, Save method. Everything you'd need to work with an XML file on disk. It also has another property that I really like: XMLDataDocument.Dataset. It's really handy.

The dataset in this case is just another dataset Just like the ones you pull out through data adapters, this one just represents the XML data as a dataset.

To use it, you need to feed it an XML schema. It'll then create the dataset and populate it with the XML data from the document.

Presumably (although I haven't had a chance to ty this yet) taht also means you can use the XMLDataDocument.Dataset to represent an interpretation of the data by feeding it a different schema. Kind of like adding views to a dataset, but doing it at an earlier point in the process. I know one limitation to that is that you wouldn't be able to change the schema after you've loaded the data (you can't set a schema after the data's been loaded) but if you're looking at an app with several data-access filter option type things (if you have different sets of data used by different people) then it could be useful.

Although having said that, if you've got a need that complicated I guess you're a milion times more likely to use SQL Server instead.

Oh well. I'll keep on using it. I kinda like it for my backend code. It's currently keeping things nice and simple in my backend code.

No comments: