Sign in to follow this  

xml parser for c++

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been searching around for good xml libraries for C++, but I can't seem to find any that are really good and that expose a simple, C++ idiomatic interface. What I need is basically a simple and fast XML standard conforming parser that returns a tree of xml nodes, preferably automatically memory managed by proper destructors or use of smart pointers or pointer containers. No need for DTD validation, but there should be validation that the input is in well-formed xml. libxml2 doesn't meet these needs, as it is in C, not C++, and the C++ binding requires an awful lot of other libraries to run, which is pretty annoying when you switch work stations often and have to install all these libraries and set up paths anew. Haven't really heard much about any of the other libraries. Is Xerxes a good library? Are there other alternatives? Are there good open source alternatives that nearly meet the requirements above, that are well-written enough that it's feasible to adapt them to own needs? What would you recommend? The usage will mostly be for config files, but I'm also thinking a bit ahead that learning a good xml parsing library for C++ can be useful for all sorts of future application areas where xml is used.

Share this post


Link to post
Share on other sites
My two suggestions would be Xerces or Qt. Qt is a huge library, but it has QtXml, which is kind of nice. But, Qt is dual-licensed, so either commercial, with a steep cost, or the GPL virus.

I've also used Expat before. Expat is nice, but the one problem I had with it, is that it's all C code. I wound up having to manually write a C++ wrapper around it.

Share this post


Link to post
Share on other sites
If you want a simple, C++ style XML parser, I recommend ticpp (http://code.google.com/p/ticpp/). I commonly use Qt's XML parser, because I'm often already using Qt for my gui. However, for other projects w/o a gui, where I need a nice and simple XML parser, I use ticpp. It's small, and C++-centric. It doesn't do DTD validation, but will ensure that the XML constitutes a valid document.

Cheers,
Rob

Share this post


Link to post
Share on other sites
Quote:
Original post by rufus74
What about TinyXml?


From the ticpp website:

"'TiCPP' is short for the official name TinyXML++. It is a completely new interface to TinyXML (http://www.grinninglizard.com/tinyxml/) that uses MANY of the C++ strengths. Templates, exceptions, and much better error handling. It is also fully documented in doxygen. It is really cool because this version let's you interface tiny the exact same way as before or you can choose to use the new 'ticpp' classes. All you need to do is define TIXML_USE_TICPP."

As you can see, TiCPP is just a more C++ idiomatic wrapper for TinyXml (which, I agree, is a great library by the way).

Cheers,
Rob

Share this post


Link to post
Share on other sites
Nobody besides me has used it, but maybe this can be handy for your case, because it's very simple and the class XMLTree memory manages its children automatically.

http://lpi.googlecode.com/svn/trunk/lpi_xml.cpp
http://lpi.googlecode.com/svn/trunk/lpi_xml.h

Share this post


Link to post
Share on other sites

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this