␡
- Introduction
- Defining a Custom XML Section
- Implementing a Custom IConfigurationSectionHandler
- Adding the configSection to the Configuration File
- Food for Thought
Like this article? We recommend
Defining a Custom XML Section
Web.config and App.config files support a <configuration> element. Because XML is extensible, you can add your own custom tags. While these tags are case sensitive and must match basic XML rules—for example, tags come in pairs—you can pretty much define any kind of tags you'd like. Listing 1 includes some basic tags that might represent default player options for the aforementioned Blackjack game.
Listing 1 A custom XML section representing some externally configurable player options for Blackjack.
<playerDefaultOptions> <player name="Player 1"></player> <options> <hints value="On"></hints> <noSurrender value="Off"></noSurrender> <playHintsOnly value="On"></playHintsOnly> </options> </playerDefaultOptions>