We always use the regular app.config or web.config. But sometimes, we want our configuration files to be more flexible. Here's a simple piece of code that will allow you to use more customizable config files.
What I did here was to create an
XmlTextReader and an
XPathNavigator to make things easier for me.
xmlTextReader = new XmlTextReader (configurationPath);
The rest was simple iterations:
XPathNodeIterator iterator = _xPathNavigator.Select(XPath);
If you want to use the library, all you have to do is call the
GetValue method. Please see the sample application.
It's just a simple piece of code. Originally, it was started by a friend, Ivy. But we needed to modify the original version as the need for reusability came in. Of course, you would want to use some objects in between that will fetch the code for you. I used straightforward calls just to show how to fetch the settings (plus, I'm busy with work :p).