Validating xml parser c

03-Mar-2020 19:22

You are forced to manage context, state, and so forth.Code that reads a SAX-style API is a lot more spread out than one might hope.There is another approach to handling XML that you may want to consider, called XML data binding.

Note: This is intended to be a definitive, C -FAQ-style question for this. I did not simply appropriate those other questions because they tended to ask for something slightly more specific. Just like with standard library containers, what library you should use depends on your needs.

You have chosen: Lib XML2 Xerces's SAX-style API will work in this capacity, but Lib XML2 is here because it's a bit easier to work with.

A SAX-style API is a push-API: it starts parsing a stream and just fires off events that you have to catch.

Here's a convenient flowchart: So the first question is this: What do you need? Not toy XML, of the XML specification, not just the low-lying, easy-to-parse bits.

You need Namespaces, Doc Types, entity substitution, the works. The next question is: Does your API need to conform to DOM or SAX?

It be the actual DOM or the actual SAX, to the extent that C allows. It's pretty much the only C XML parser/writer that has full (or as near as C allows) DOM and SAX conformance. You have chosen: Lib XML2 Lib XML2 offers a C-style interface (if that really bothers you, go use Xerces), though the interface is at least somewhat object-based and easily wrapped.