1

I'm using a configuration file such that when the user needs to change the configurations, I don't have to recompile the code. Currently I have a specific configuration structure that I parse myself. I was recently suggested to use XML.

I'm using libxml2 in c++ and I'm looking for a generic way to parse the XML configuration file, so that when I change the structure of the xml tree in the future I don't have to change the parsing function so much.

Can you please suggest a standard way to parse the XML file generically not depending on the structure or the type?

Some things to note:
1. The XML is built such that only the leafs hold the values of the configuration and the tree XML structure is just for readability purposes.
2. The values of the XML file can be string or int or array etc and I would like to store that XML value according to the type.
3. If you're suggesting some library, please suggest libraries that could be used commercially too.
4. I would like the parsing not to be a long function of strcmp

I hope the question is clear enough, Thanks in advance!

1 Answer 1

1

I can suggest using Boost Property Tree library that supports XML as one of the several formats.

Alternatively you might take a look at rapidxml library (AFAIK it is used internally by Boost). It's very small, header-only library that you just have to copy into your project. No separate compilation or dependency is needed in this case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.