[Taken from the standard expat distribution] */ #include This program simply shows the string "I found the element" followed by the element name for each element found.Note the existence of a void *user Data parameter that expat uses to give you the possibility of managing your information across calls.IBM's parser will be re-released at the end of this year as "Xerces," part of the new Apache XML Project.Expat is a C parser developed and maintained by James Clark.It is also under the GPL (the GNU General Public License), which means you can freely use and distribute it.
Expat has many advantages: it is very fast and very portable.
and so on for the other handlers like // processing Instruction Callback // At the constructor, expatpp creates an expat parser and registers // the callbacks expatpp::expatpp() // Now, for each callback there is a partner override-able member // like virtual void start Element(const XML_Char* name, const XML_Char** atts) // All a callback does is to call its partner method inline void expatpp::start Element Callback (void *user Data, const XML_Char* name, const XML_Char** atts) // In runtime, when the parser begins calling the callback, the // appropriate method overridden in your derived class will be // called.
For the complete code look at expatpp.[h|c] As you can see, the user Data is used to maintain a pointer to your expatpp object.
It is event-driven, in the sense that it calls handlers as parts of the document are encountered by the parser.
User-defined functions can be registered as handlers.