Using the XML parser for Symbian C++
Article Metadata
Compatibility
S60 3rd Edition
Article
Overview
Using the XML parser in S60
Description
XML parser framework is available for the S60 platform starting from 2nd Edition, Feature Pack 2.
CParser is a SAX-like parser, which parses XML files or XML strings, element by element. To use it, a content handler class derived from MContentHandler must be implemented. The content handler class implements interface methods such as OnStartElementL() and OnEndElementL(), which are then called by the parser (CParser) for each XML tag. The content handler implementation and MIME type of the parsed document are passed to the CParser object at construction.
EXAMPLE CODE:
// Link against xmlframework.lib
#include <xml/parser.h>
#include <xml/contenthandler>
#include <xml\XmlFrameworkConstants.h
// Implements MContentHandler interface
CMyContentHandler sax;
// Mime type of the parsed document
_LIT8(KXmlMimeType, "text/xml");
// Contruct the parser object
CParser* parser = CParser::NewLC(KXmlMimeType, sax);
// Start parsing XML from a descriptor
// CMyContentHandler will receive events
// generated by the parser
parser.ParseL(aDesMyXML);
// Destroy the parser when done.
CleanupStack::PopAndDestroy();


(no comments yet)