How to parse XML file using CParser class
Reviewer Approved
The following example shows how to parse XML file using Symbian OS C++ class, CParser. CParser is basically a SAX (Simple API for XML)-based XML parser.
It uses an active object to read the XML file chunk by chunk (see CXmlHandler::StartParsingWithAoL() method). On each chunk, it passes the buffer to the XML parser. When the XML parser finds an element, it calls the respective callback functions, for example CXmlHandler::OnStartElementL() or CXmlHandler::OnEndElementL().
To use CParser class, the XmlFramework.lib has to be included in the .mmp file. For more information about CParser, please visit some links at the end of this page.
Contents
[hide]
1 XmlHandler.h
2 XmlHandler.cpp
3 download example
4 See Also
[edit] XmlHandler.h
#ifndef __XMLHANDLER_H__
#define __XMLHANDLER_H__
// INCLUDE FILES
#include <e32base.h>
#include <f32file.h> //Link against efsrv.lib
#include <xml\contenthandler.h> // for MContentHandler
#include <xml\parser.h> // for CParser
// CLASS DECLARATION
using namespace Xml;
class CXmlHandler: public CActive, MContentHandler
{
public: // Constructors and destructor
static CXmlHandler* NewL();
static CXmlHandler* NewLC();
virtual ~CXmlHandler();
public: // Public methods
void StartParsingWithAoL( const TDesC& aFileName );
private: // Constructors
CXmlHandler();
void ConstructL();
private: // from CActive
void DoCancel();
void RunL();
private: // from MContentHandler
void OnStartDocumentL( const RDocumentParameters &aDocParam,
&n
相关文档:
在平时工作中,难免会遇到把XML作为数据存储格式。面对目前种类繁多的解决方案,哪个最适合我们呢?在这篇文章中,我对这四种主流方案做一个不完全评测,仅仅针对遍历XML这块来测试,因为遍历XML是工作中使用最多的(至少我认为)。
预备
测试环境:
AMD毒龙1.4G OC 1.5G、256M DDR333、Windows2000 Server SP ......
任何ORM的解决方案都应该提供一种易读的、容易编辑的映射文件格式,而不仅仅提供一个GUI图形工具。当下流行的对象/关系元数据格式都支持XML。使用XML格式的文件可以提供如下好处:首先它是轻量级的,提供很好的易读性,能够进行版本控制,可以在部署阶段定制。
但是XML格式文件真的是最好的选择吗?Java社团中就反对XML ......
//xml文档内容
<?xml version = "1.0" encoding="gb2312" standalone="yes"?>
<VFPData>
<company>
<companyno>100</companyno>
<companyname>上海</companyname>
<ceoname>陈四</ceoname>
<ceoma ......
2009-10-27 22:44资料来源于网络,四种方式,大家可以自己尝试下.
=========11111=================
tinyXML
www.grinninglizard.com/tinyxml/
=========22222================================
symbian s60 第三版之后,已经提供了解析xml的系统api,采用的是SAX方式。
XML parsing in Symbian OS v9.x 来源目录:
htt ......