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 ......
1)DOM(JAXP Crimson解析器)
DOM是用与平台和语言无关的方式表示XML文档的官方W3C标准。DOM是以层次结构组织的节点或信息片断的集合。这个层次结构允许开发人员在树中寻找特定信息。分析该结构通常需要加载整个文档和构造层次结构,然后才能做任何工作。由于它是基于信息层次的,因而DO ......
Xml, xslt, xsd, xpath描述一下
XML: Extensible Markup Language扩展标记语言,用来处理结构化文档。
XSLT: XSL Transformations。用来将一种XML转换成另外一种XML文档。也可以将XML转换成XHTML或者HTML在浏览器中显示。
XSD: XML Schemas Definition。用来定义XML文档的结构。XML Schema 是DTD(Document Type Definiti ......
数据库应用系统包括数据库,数据库管理系统,数据库应用三大部分。
世界上存在许多完全不同的客户平台,在不同平台间交换数据,需要保证数据的完整和服务的高效,数据格式的转换问题往往成为制约Web Service的瓶颈,采用XML作为数据交换的标准,可以使各个异构平台和各种格式的数据进行数据交换成为可能。
......
Web 使我们能够与任何地方的任何人通讯。广泛接受的标准(这对完全使用 Web 的潜力是至关重要的)允许 Web 在多种交互操作的技术层上通讯。一个重要层是可视化显示和用户界面,例如 HTML、GIF 和 JScript(TM) 之类的现有标准。这些标准允许创建一次页面,并且在不同时间向众多接收者显示。
尽管可视化和用户界面标准是必 ......