XML Demo VB.NET Source Code

XML Demo

A program that demonstrates how to persist VB.NET application settings using an XML document. This is basically (notice the pun) an example of how to use an XML file to persist settings in your application. The coding convention is the same as the VB SaveSettings or GetSettings, also the same as the old INI file convention. You use a Section to separate different types of settings then a key=value pair to store individual settings.

Why use it?

Considering that you can serialize objects in VB.NET, why would you use this at all? What value does it have beyond just being an example of a niche programming task? This convention makes it very easy to save any type of values (boolean, string, integer) from your appliction to an xml file then reload them when they are required. The class will automatically assign a file name to the xml settings file or you can assign one yourself. The xml file is loaded into an XML Document instance when the class is instantiated, any information you add or change is saved to the disk file automatically when the class is destroyed. Use this class any time you would use an INI file; then you won't be bound by the limitations of the ini text format - your file will be in XML so it's more portable, more compatible.

How does the code look?

The class comes with all code and debugging files, including a simple but very well documented demonstration application which shows you how to save and load values to the xml file. The class itself is also very well documented. The code was written in Visual Studio 2003 - if the project won't load into your version of Visual Studio, complain to Microsoft. I'm not the one who broke compatibility between versions of Visual Studio project files. Do NOT specify any values that are invalid as XML Document values. I found out the hard way that MSXML will not save some characters as part of an XML node (notably the pound sign).

Why is it useful?

So, beyond just being an example, how is it useful?