Click here to Skip to main content
13,588,766 members
Click here to Skip to main content
Add your own
alternative version


38 bookmarked
Posted 27 Jul 2004

A STL based XML Config Tool

, 19 Jun 2005
Rate this:
Please Sign up or sign in to vote.
Writing multiple enumerated configuration entries.


In an application, I needed the possibility to have an easy way for reading and writing configuration data to a file. Further, I needed the possibility to nest different Settings into each other for a better representation of how the data is in relation to each other. XML seemed to be the solution. Not having any knowledge about XML, I found two great articles on CodeProject: Read and Write application parameters in XML from Arnaud Brejon, and A simple STL based XML parser by David Hubbard.

The problem using this code was that it was not able to use equal names of configuration keys and that would lead to the need of enumeration. I did an enumeration of different keys before using INI – files. That is really ugly if you need to delete keys, because you have to change the whole enumeration of keys after the deleted one. The solution would be a configuration tool allowing keys of equal names. Many developers seemed to have the same needs, and so I hope that this article helps a bit.

All I had to do was to add some little code and write a wrapper class around Arnoud Brejon's ParamIO - class. The data written, when using equal entry names, is embedded into the XML Nodes attributes.

Using the code

All you need is the XmlConfig – class that actually wraps a ParamIO object.

XmlConfig aParam;
aParam.write( "Test:Blub:SecondNode", "Whatever" );
aParam.AddAttributeString( "Test:FirstNode:Blub:SomeAttrib",
        "stringAttrib = \"SomeValue\" intVal = \"12345\"", 0 );
aParam.AddAttributeString( "Test:FirstNode:Blub:SomeAttrib",
        "stringAttrib = \"SomeOtherValue\" intVal = \"12345678\"", 0 );
aParam.writeFile( "c:\\Blub.xml" );

A kind of type checking is already included (but not handled yet). The parser interprets the "int" in intVal to determine which type the value is. If no matching (or supported) type is found, a normal string is assumed.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Tobias Wenig
Software Developer
Germany Germany
Studying and having a degree of medical engineering, but decided to work as a software developer writing medical applications for image processing.

You may also be interested in...


Comments and Discussions

GeneralLicense Pin
Lars Wetzel18-Apr-11 4:58
memberLars Wetzel18-Apr-11 4:58 
Hi Tobias,

only a short question about the license:
Can I assume that the code is under CPOL?

GeneralRe: License Pin
Tobias Wenig18-Apr-11 5:04
memberTobias Wenig18-Apr-11 5:04 
GeneralUnable to read the data Pin
Staffan O14-Jun-05 23:32
sussStaffan O14-Jun-05 23:32 
GeneralRe: Unable to read the data Pin
Tobias Wenig15-Jun-05 1:06
memberTobias Wenig15-Jun-05 1:06 
GeneralRe: Unable to read the data Pin
Staffan O15-Jun-05 4:55
memberStaffan O15-Jun-05 4:55 
GeneralRe: Unable to read the data Pin
Tobias Wenig17-Jun-05 4:46
memberTobias Wenig17-Jun-05 4:46 
Generalvs2003 Pin
vv12329-Jul-04 17:50
membervv12329-Jul-04 17:50 
GeneralRe: vs2003 Pin
Tobias Wenig30-Jul-04 1:37
memberTobias Wenig30-Jul-04 1:37 
GeneralRe: vs2003 Pin
Tobias Wenig5-Aug-04 22:13
memberTobias Wenig5-Aug-04 22:13 
GeneralRe: vs2003 Pin
iceber12-Aug-04 23:07
membericeber12-Aug-04 23:07 
GeneralRe: vs2003 Pin
Tobias Wenig19-Aug-04 5:51
memberTobias Wenig19-Aug-04 5:51 
GeneralNice! Pin
Arnaud Brejeon28-Jul-04 13:24
memberArnaud Brejeon28-Jul-04 13:24 
GeneralKudos Pin
Nitron28-Jul-04 10:38
memberNitron28-Jul-04 10:38 
GeneralExactly what I needed Pin
boz28-Jul-04 4:21
memberboz28-Jul-04 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.180615.1 | Last Updated 20 Jun 2005
Article Copyright 2004 by Tobias Wenig
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid