What XML libraries are out there, which are minimal, easy to use, come with little dependencies (ideally none), can be linked statically and come with a liberal license? So far, I've been a pretty happy user of TinyXML, but I'm curious what alternatives I have missed so far.
expat is a very fast C XML parser (although a C++ wrapper exists) that's widely used in many open-source projects. If I remember correctly, it has very few dependencies, and it's licensed under the very liberal MIT License.
I recommend rapidxml. It's an order of magnitude smaller than tinyxml, and doesn't choke on doctypes like tinyxml does.
If you need entity support or anything advanced, forget about static linking and use expat or libxml2.
FWIW there is also a version of TinyXML with a more C++-like interface, called ticpp.
There's one called libxml2.
There's also a Windows-only solution, a COM library that's part of the O/S, called msxml.
In "what’s the easiest way to generate xml in c++?" I wrote a comment that lists a few C++ XML libraries
TinyXML++ (ticpp) was, IMHO, the most appropriate for a small, easy to use XML library in C++.
Related
I depend heavily on Python's standard library, both for useful data structures and manipulators (e.g., collections and itertools) and for utilities (e.g., optparse, json, and logging), to skip the boilerplate and just Get Things Done. Looking through documentation on the C++ standard library, it seems entirely about data structures, with little in the way of the "batteries included" in Python's standard library.
The Boost library is the only open-source C++ library collection I know of that resembles the Python standard library, however while it does have utility libraries such as Regular Expression support, most of it is also dedicated to data structures. I'm just really surprised that even something as simple as assured parsing and writing a CSV file, made delightfully simple with the Python csv module, looks to require rolling-your-own in C++ (even if you leverage some parsing library by Boost).
Are there other open-source libraries out there for C++ that provide "batteries"? If not, what do you do as a C++ programmer: hunt for individual utility libraries (and if so, how), or just roll your own (which seems annoying and wasteful)?
The Poco library is more like other languages' standard libraries.
Actually the Poco web site's logo says "C++ now comes with batteries included!", which seems to be precisely what you're asking for.
I didn't like it when I tried because I found it too C-like and with too many dependencies between parts (difficult to single out just the functionality you want).
But there are many people & firms using it, so it seems I'm in minority and you will perhaps find it very useful.
In addition, as others have mentioned, for data structures, parsers, and indeed an interface to Python!, and such stuff, check out Boost.
Cheers & hth.,
While C++ does offer many of the comforts extended by OO it keeps a very simple standard library. C++ has STL and Boost. These are very good, and have more then just datastructures.
If your needs are these sorts of higher order functions for prototyping or making application without intense (relative term) speed requirements then C/C++ is probably not the right choice for you. I believe you will find that for most projects that high level languages will be fast enough for your needs. If you are working on an application that requires C/C++ speed (and accompanying standard deviations) then you should probably invest your time carefully picking each individual library you will be using.
http://beta.boost.org/community/sandbox.html
http://www.boostpro.com/vault/
also you can google for "boost+bar", eg
boost log ->
http://boost-log.sourceforge.net/libs/log/doc/html/index.html
boost threadpool ->
http://threadpool.sourceforge.net/
http://www.boost.org/doc/libs/1_45_0/?view=categorized
Boost isn't just about data structures - it has lots of the batteries you want - parsing, threads, collections, logging, etc.
With C and C++ you typically won't find a "do it all" library, instead you'll use individual libraries that do different things. You can use one library that does JSON parsing, one that does crypto, one that does logging, etc.
Boost and Qt are the only ones that would be more of a "do it all" type library.
I'm looking for a simple non-validating XML parser in either C or C++.
Several years back I found one that was just a single file solution but I can't find
it anymore.
I'm after some links and suggested ones that are very small and lightweight
ideally suited for an embedded platform.
Expat
You can work with or without validation and in "streaming mode". It is very lightweight.
What about something like pugixml. From their site...
pugixml is a light-weight C++ XML
processing library. It features:
DOM-like interface with rich traversal/modification capabilities
Extremely fast non-validating XML parser which constructs the DOM
tree from an XML file/buffer
XPath 1.0 implementation for complex data-driven tree queries
Full Unicode support with Unicode interface variants and
automatic encoding conversions
The library is extremely portable and
easy to integrate and use.
pugixml is developed and maintained
since 2006 and has many users. All
code is distributed under the MIT
license, making it completely free to
use in both open-source and
proprietary applications.
Also, this answer has more info.
There is also tinyxml and RapidXml.
There is definitely a pure C, tiny xml parser available. It was cited in an earlier answer on SO, but I can't find it right now. If I remember right, it's just a few hundred lines of code.
Update: Here's the question/answer that references it:
Is there a good tiny XML parser for an embedded C project?
And the actual code:
http://mercurial.intuxication.org/hg/cstuff/file/tip/tinyxml
RapidXML is a single-header (multiple headers if you want extra functionality) ultra-lightweight, ultra-fast implementation. It can operate in "destructive" mode, that means by setting pointers right into the XML and possibly overwriting some, avoiding all extra memory allocations and data copies.
tinyxml is not precisely single-header, but it is still fairly lightweight compared to other parsers. I've used it for half a decade without ever encountering an issue. The author has recently started with "tinyxml-2", which is supposedly better and even more lightweight, but I've not had occasion to actually try that one yet.
http://mercurial.intuxication.org/hg/cstuff/file/tip/tinyxml
can this parser work with nested XML like
<CServiceType>
<serno>61</serno>
<caption1 />
<caption2>Satelite</caption2>
<caption3 />
</CServiceType>
I was wondering what is the best XML Library in C++ (I'm using Visual Studio), considering fast set-up is critical. Basically, I want to create a file to save annotations on various .avi files.
Thank you in advance.
You should be able to get TinyXML set up and working in a matter of minutes.
TinyXML is simple enough for almost all your use (if you don't bother having the whole xml representation in memory) but other libraries offer better important features :
RapidXML is made to be really really fast. It's used in the boost::property_tree library for the xml file read/write features. If you already use boost, using directly boost::property_tree might be a good idea, if adequate, as you already can easily use it with it's simple interface.
pugiXML has been mentionned as a good replacement for RapidXML by someone on the boost mailing list, but I'm not aware of the differences.
Xerces-C++ is made to allow you high level manipulations on xml like validation using xsd files -- but is really heavy on both speed and memory size...
wrappers around classic C xml libraries (like LibXML2) might be interesting choice if you don't find what you're looking for with the previous ones...
I've used XercesC++ in the past and it was relatively painless to get working and working with.
I'm currently using MSXML and it is painful.
I'm coming to C++ from a .Net background. Knowing how to use the Standard C++ Libraries, and all the syntax, I've never ventured further. Now I'm looking learning a bit more, such as what libraries are commonly used? I want to start getting into Threading but have no idea to start. Is there a library (similar to how .net has System.Threading) out there that will make it a bit easier? I'm specifically looking to do Linux based network programming.
For C++, Boost is your everything. Threading and networking are among the things it offers. But there's much more:
Smart pointers
Useful containers not found in the STL, such as fixed-size arrays and hashtables
Closures
Date/time classes
A foreach construct
Min/max functions
Command line option parsing
Regular expressions
As the others have said, Boost is great. It implements the C++ Technical Report 1 in addition to tons of other stuff, including some mind-blowing template metaprogramming tricks.
For other cross-platform features not provided by Boost, I've had very good luck with a library called Poco. I've worked on commercial projects that incorporated its simple HTTP server, for instance, and it treated us quite well.
lots of boost suggestions, but Qt is another good option. It's got great support for threading and networking along with pretty much everything else.
http://qt.nokia.com/products
If you are looking into network programming and are not interested into GUI, I suggest Boost libraries: in particular, Asio.
There's no standard multithreading library, but the boost library includes a platform-independent multithreading abstraction that works very well.
We are aware of MSXML, based on COM technologies. We want to use it for a VC++ project starting soon. Are there any other XML libraries do good compared to MSXML?
TinyXML - A C++ open source library
Will you be using the .Net Framework if so you may want to look at using linq to xml.
Take a look at RapidXML. Also, Boost.PropertyTree is an abstraction over property trees (XML, JSON, INI, INFO at the time of writing) and relies on RapidXML for its XML parser.
We ditched MSXML in favor of Xerces for our project, although Xerces is also a big, complicated beast. The TinyXML suggestion is probably a good one if it does everything you need it to. If you only need basic SAX model support (and not a DOM), then you might also consider expat which is one of the first widely used XML parsers.
LIBXML
"Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), it is free software available under the MIT License."
I have used it for many years on Win32 projects without problem. It supports both SAX and DOM style reading.
You must take a look at Microsoft XmlLite which is a pull parser for pure C++. The primary goals of XmlLite are ease of use, performance, and standards compliance.