×
Namespaces

Variants
Actions

Using the XML parser for Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Compatibility
Platform(s): S60 2nd Edition FP2, FP3
S60 3rd Edition
S60 3rd Edition (initial release)
S60 2nd Edition (initial release)
Article
Created: User:Technical writer 2 (25 Aug 2005)
Last edited: hamishwillee (14 Jun 2012)

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();

This page was last modified on 14 June 2012, at 09:27.
50 page views in the last 30 days.