Best XML Library in C++, Fast Set-Up - c++

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.

Related

Parsing xml file using xerces C++

I have an xml file to be parsed for the information contained to be further used. Can anyone help me with the xerces C++ code for parsing it? I have the xml creation code using xerces library as well in C++.
Maybe this doesn't help you much if you're already committed to xerces, but I'd recommend using pugixml instead. It's very easy to integrate, is very performant and has excellent documentation. I built a rather large project using it and had nothing but good experiences with it. It's of the nicest libraries I've ever used. (I'm not affiliated with them; just very happy).
Here is the documentation on parsing files: http://pugixml.googlecode.com/svn/tags/latest/docs/manual/access.html

Read XML on LINUX

I have requirement where we have to read a small XML file on Linux. Our application is in C++ and I like to use any light weight XML library. Please suggest me the library.
Thanks
You can Try pugixml Light-weight, simple and fast XML parser for C++
As a 2nd option look at TinyXML
Have a look also at TinyXml (http://sourceforge.net/projects/tinyxml). It is extremely lightweight and for this reason it is used also in mobile and game programming. The API is minimal though so you have to evaluate if it fully satisfy your needs.
This xml parser is good
There is xerces-c for that. It's complete, but I don't know if you will find it small enough. Your question is relative to what?

Single file non-validating xml parser/reader

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>

c/c++ XML library question

I know that a lot of c/c++ XML library questions have been asked already (I tried to read through all of them before getting to this).
Here are the things I'm going to need in my own project:
Excellent performance
SAX2
Validation
Open source
Cross platform
I was going to use Xerces-C, but I see that a simple SAX2 setup with nothing going on in the filter is taking 5 seconds to run. (Perhaps I'm doing something wrong here?)
I would like to use libxml++, but as I tried to get it set up on my MacBook, there were some crazy dependencies that took me all the way back to gtk-doc, at which point I sort of tabled the idea.
So now I'm at libxml2. Is this the way to go? Have I missed an important option, bearing in mind the five requirements above? I don't mind using a (good) c-library like libxml2, but a c++ interface would be nice. (I don't like Xerces-C's API very much.)
I am willing to bend on the SAX2 requirement if comparable functionality is available.
Having spent a goodly amount of time on this same problem, it was my conclusion that libxml2 is the best option available under your guidelines. The C interface is not too difficult to use and it's very fast.
There are some other good options for commercial libraries, but most of the other comparable open-source options are either painfully slow or are mired in a deep, annoying vat of dependency soup.
You say you need these things in your project, but don't give any idea of the pipeline. For example, we had a whole load of static XML files which needed to be loaded quickly, but only validated rarely. So validated using a separate process in batch (using RelaxNG as it was human writable markup ) and loaded the XML using expat. The system also used XMPP, so checked streaming input, but that didn't require validating against a schema (partly because it was streamed, and mostly because most of the possible errors were not expressible in a schema).
If you need a whole host of other facilities, you can consider Qt, which has good XML support. Be warned though, it's WAY more than an XML processing library; it's a full blown application framework with support for GUIs, networking and a whole host of other things.
Qt
You can also try Poco. It's another application framework, but not as huge as Qt (i.e. no GUI-related things etc.)
Poco
Lastly, if you don't mind a C library, you can use Expat. It's not SAX per se, but writing code using Expat is somewhat like SAX. It has C++ wrappers, but they're not officially part of the project IIRC, and may not be as well-maintained or designed. I'm not too sure though.
Expat
Hope this helps!
EDIT: I misread your original post: not too sure about the validation features of these libraries, I've never used them before.

Minimal XML library for C++?

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++.