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
Ïà¹ØÎĵµ£º
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<name>¹þÀï²¨Ì ......
function $import(path,type,title,idname){
var s,i;
if(type=="js"){
&nb ......
µÚÒ»²½:½«XML±à¼Æ÷ÉèÖÃĬÈÏΪMyeclipse edit
window__Preferences__General____Editors_____File Associations
ÕÒµ½*.xml,Ñ¡ÔñMyeclipse Xml editor,µãdefault
µÚ¶þ²½:ÅäÖÃdtd»òÕßxsdÎļþ
Window → Preferences... → MyEclipse → Files & Editors → ......
ÈκÎORMµÄ½â¾ö·½°¸¶¼Ó¦¸ÃÌṩһÖÖÒ׶ÁµÄ¡¢ÈÝÒױ༵ÄÓ³ÉäÎļþ¸ñʽ£¬¶ø²»½ö½öÌṩһ¸öGUIͼÐι¤¾ß¡£µ±ÏÂÁ÷ÐеĶÔÏó/¹ØϵԪÊý¾Ý¸ñʽ¶¼Ö§³ÖXML¡£Ê¹ÓÃXML¸ñʽµÄÎļþ¿ÉÒÔÌṩÈçϺô¦£ºÊ×ÏÈËüÊÇÇáÁ¿¼¶µÄ£¬ÌṩºÜºÃµÄÒ׶ÁÐÔ£¬Äܹ»½øÐа汾¿ØÖÆ£¬¿ÉÒÔÔÚ²¿Êð½×¶Î¶¨ÖÆ¡£
µ«ÊÇXML¸ñʽÎļþÕæµÄÊÇ×îºÃµÄÑ¡ÔñÂð£¿JavaÉçÍÅÖоͷ´¶ÔXML ......
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 ......