Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Light weight C++ SAX XML parser

Tags:

c++

xml

sax

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

like image 358
John Bartholomew Avatar asked Jan 13 '11 19:01

John Bartholomew


People also ask

Why is SAX parser faster than DOM?

A SAX parser, however, is much more space efficient in case of a big input document (because it creates no internal structure). What's more, it runs faster and is easier to learn than DOM parser because its API is really simple.

Is XML easy to parse?

Well parsing XML is not an easy task. Its basic structure is a tree with any node in tree capable of holding a container which consists of an array of more trees.

What are the limitations of SAX in XML?

1)SAX is an event-driven push model for processing XML. It is not a W3C standard, 2)Rather than building a tree representation of an entire document as DOM does, a SAX parser fires off a series of events as it reads through the document. 4) you have to keep track of where the parser is in the document hierarchy.

What is XML parser in C?

The Oracle XML parser for C reads an XML document and uses DOM or SAX APIs to provide programmatic access to its content and structure. You can use the parser in validating or nonvalidating mode. This chapter assumes that you are familiar with the following technologies: Document Object Model (DOM).


1 Answers

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.

like image 155
sbi Avatar answered Oct 05 '22 06:10

sbi