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
Ïà¹ØÎĵµ£º
function $import(path,type,title,idname){
var s,i;
if(type=="js"){
&nb ......
CollectionÖ÷ÒªÊÇÖ¸ÏñArray, ArrayList, List, Dictionary, HashTableÕâЩÊý¾ÝÀàÐÍ£¬´ó¼ÒƽʱÓõĺܶࡣÈç¹ûÒ»¸öÀàÖÐÓÐÒ»¸öCollectionÀàÐ͵ijÉÔ±£¬ÔÚ¶ÔÕâ¸öÀà½øÐÐXMLÐòÁл¯µÄʱºò£¬Ó¦¸ÃÈçºÎ´¦Àí£¿Ó¦¸Ã˵ÔÚ.netµ±ÖÐÕâÊDZȽϼòµ¥µÄ£¬Ö»Òª½¨Á¢Ò»¸öXmlSerializerÀà¾Í¿ÉÒÔ°ïÄã×Ô¶¯¸ã¶¨£¬²»¹ýÓеÄʱºòÄã¿ÉÄÜÐèÒª¶Ô×Ô¶¯µÄÐòÁл¯¹ý³ ......
½âÎö£º
CMarkup xml;
CString strChanText, strChanType;
xml.Load("MyXml.xml");
xml.ResetMainPos();
if (!Chan.FindElem("TreeOrg"))
{
return;
}
if (xml.IntoElem())
{
xml.FindEle ......
ÈκÎORMµÄ½â¾ö·½°¸¶¼Ó¦¸ÃÌṩһÖÖÒ×¶ÁµÄ¡¢ÈÝÒױ༵ÄÓ³ÉäÎļþ¸ñʽ£¬¶ø²»½ö½öÌṩһ¸öGUIͼÐι¤¾ß¡£µ±ÏÂÁ÷ÐеĶÔÏó/¹ØÏµÔªÊý¾Ý¸ñʽ¶¼Ö§³ÖXML¡£Ê¹ÓÃXML¸ñʽµÄÎļþ¿ÉÒÔÌṩÈçϺô¦£ºÊ×ÏÈËüÊÇÇáÁ¿¼¶µÄ£¬ÌṩºÜºÃµÄÒ×¶ÁÐÔ£¬Äܹ»½øÐа汾¿ØÖÆ£¬¿ÉÒÔÔÚ²¿Êð½×¶Î¶¨ÖÆ¡£
µ«ÊÇXML¸ñʽÎļþÕæµÄÊÇ×îºÃµÄÑ¡ÔñÂð£¿JavaÉçÍÅÖоͷ´¶ÔXML ......