Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous Page Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

XML Event-Based Parsing

QuickTime 5 now includes an XML parsing component. In addition to tree-based XML parsing, it supports event-based XML parsing. This is supported through callbacks to the client.

Event-based parsing uses much less memory than the tree-based parser. Basically, it does a callback anytime something interesting happens. To invoke this, you pass the xmlParseFlagEventParseOnly flag to XMLParseDataRef() or XMLParseFile(). The XMLDoc parameter should be set to NULL in this case. The handlers (which need not all be set) are defined as follows:

ComponentResult startDocumentHandler(long refcon);
ComponentResult endDocumentHandler(long refcon);
ComponentResult startElementHandler(const char *name, const char **atts,
                                    long refcon);
ComponentResult endElementHandler(const char *name, long refcon);
ComponentResult charDataHandler(const char *charData, long refcon);
ComponentResult commentHandler(const char *comment, long refcon);
ComponentResult preprocessHandler(const char *name, const char **atts,
                                    long refcon);

The following APIs set the callbacks along with the common refcon shared among the callbacks:

pascal ComponentResult XMLParseSetEventParseRefCon(ComponentInstance
                                        aParser, long refcon);
pascal ComponentResult XMLParseSetStartDocumentHandler(ComponentInstance
                                        aParser, StartDocumentHandlerUPP
                                        startDocument);
pascal ComponentResult XMLParseSetEndDocumentHandler(ComponentInstance
                        aParser, EndDocumentHandlerUPP endDocument);
pascal ComponentResult XMLParseSetStartElementHandler(ComponentInstance
                        aParser, StartElementHandlerUPP startElement);
pascal ComponentResult XMLParseSetEndElementHandler(ComponentInstance
                            aParser, EndElementHandlerUPP endElement);
pascal ComponentResult XMLParseSetCharDataHandler(ComponentInstance
                            aParser, CharDataHandlerUPP charData);
pascal ComponentResult XMLParseSetPreprocessInstructionHandler(ComponentInstance  aParser,
                                PreprocessInstructionHandlerUPP
                                preprocessInstruction);
pascal ComponentResult XMLParseSetCommentHandler(ComponentInstance
                                aParser, CommentHandlerUPP comment);

It is the client’s responsibility to create and free any UPPs it sets. Also, the atts parameter returned in the start element and preprocess handlers is a character string array that contains the attribute name followed by the attribute value. The list ends with a null terminator.



< Previous Page Hide TOC


Last updated: 2001-10-01




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice