Light weight C++ SAX XML parser
Asked Answered
N

3

12

I know of at least three light weight C++ XML parsers: RapidXML, TinyXML and PugiXML. However, all three use a DOM based interface (ie, they build their own in-memory representation of the XML document and then provide an interface to traverse and manipulate it). For most situations that I have to deal with, I much prefer the SAX interface (where the parser just spits out a stream of events like start-of-tag, and the application code is responsible for doing whatever it wants based on those events).

Can anyone recommend a light weight C++ XML library with a SAX interface?

Edit: I should also note the Microsoft XmlLite library, which does use a SAX interface (well, actually a "pull" interface which is possibly even better). Unfortunately, it's ruled out for me at the moment since as far as I know it's closed source and Windows only (please correct me if I'm wrong on this).

Noriega answered 13/1, 2011 at 19:39 Comment(1)
github.com/igagis/mikroxmlNinfaningal
S
10

I've used expat when I needed to parse XML. It's very light-weight (well, it used to be; it's a while since I've done XML stuff) and does the job.

Superheat answered 13/1, 2011 at 19:45 Comment(5)
I must admit I didn't give expat the attention it deserved. Do you use it with a C++ wrapper? If so, which one?Noriega
@John: It took me a while to remember, but when I did this, I used this one: beta.codeproject.com/KB/XML/expatimpl.aspx. But that was only a very thin wrapper and it is now seriously outdated.Superheat
Alright. Looks like expat is reasonable, even if I put my own C++ wrapper over it.Noriega
what about TinyXML and its C++ wrapper TinyXML++?Fley
@Monomer: I don't know. The only parser I ever used (after looking at a few of them many years ago) was expat. Maybe TinyXML is as good or even better. I wouldn't know.Superheat
E
6

you can try https://github.com/thinlizzy/die-xml . it seems to be very small and easy to use

this is a recently made C++0x XML SAX parser open source and the author is willing feedbacks

it parses an input stream and generates events on callbacks compatible to std::function

the stack machine uses finite automata as a backend and some events (start tag and text nodes) use iterators in order to minimize buffering, making it pretty lightweight

Esplanade answered 23/11, 2011 at 14:49 Comment(0)
T
-3

PugiXML and RapidXML do not have DOM conforming interfaces.. those API came with severe limitations on functionalities and conformance. You might want to investigate VTD-XML that is signifiantly more advanced than either DOM or SAX/Pull

Tamekia answered 13/1, 2011 at 22:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.