Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

ÔÚ.net µ±ÖÐÈçºÎXMLÐòÁл¯Ò»¸öCollection

CollectionÖ÷ÒªÊÇÖ¸ÏñArray, ArrayList, List, Dictionary, HashTableÕâЩÊý¾ÝÀàÐÍ£¬´ó¼ÒƽʱÓõĺܶࡣÈç¹ûÒ»¸öÀàÖÐÓÐÒ»¸öCollectionÀàÐ͵ijÉÔ±£¬ÔÚ¶ÔÕâ¸öÀà½øÐÐXMLÐòÁл¯µÄʱºò£¬Ó¦¸ÃÈçºÎ´¦Àí£¿Ó¦¸Ã˵ÔÚ.netµ±ÖÐÕâÊDZȽϼòµ¥µÄ£¬Ö»Òª½¨Á¢Ò»¸öXmlSerializerÀà¾Í¿ÉÒÔ°ïÄã×Ô¶¯¸ã¶¨£¬²»¹ýÓеÄʱºòÄã¿ÉÄÜÐèÒª¶Ô×Ô¶¯µÄÐòÁл¯¹ý³ ......

ÓÃCMarkUpÀà½âÎöXMLÎļþ

½âÎö£º
 CMarkup xml;
 CString strChanText, strChanType;
 xml.Load("MyXml.xml");
 xml.ResetMainPos();
 if (!Chan.FindElem("TreeOrg"))
 {
      return;
 }
 if (xml.IntoElem())
 {
      xml.FindEle ......

Symbianѧϰ±Ê¼Ç(15) ½âÎöXMLÎļþ(ÉÏ)

ÊÕ²Ø
ÎÒÔøÔÚÇ°Ãæ½éÉܹýÒ»¸ö¿ÉÓÃÓÚBREW»·¾³ÏµÄXML Parser£¬½ñÌìÏë·ÖÏíµÄÊÇÈçºÎÔÚSymbianƽ̨ÉϽâÎöXMLÎļþ£¬²»ÐèÒªµÚÈý·½µÄ¶«Î÷£¬SymbianÒѾ­ÎªÎÒÃÇÌṩÁËÕâ¸öÀàCParser¡£
ÍøÉÏÒ²ÓÐÕâ·½ÃæµÄ×ÊÁÏ£¬½¨Òé²Î¿¼£º
http://wiki.forum.nokia.com/index.php/How_to_parse_XML_file_using_CParser_class
²»¹ý£¬Òª×¢ÒâµÄÊÇSymbia ......

Symbianѧϰ±Ê¼Ç(16) ½âÎöXMLÎļþ(ÏÂ)


×ÖºÅ:  С  ÖР ´ó  | ´òÓ¡ ·¢²¼: 2009-1-08 16:33    ×÷Õß: webmaster    À´Ô´: ±¾Õ¾Ô­´´    ²é¿´: 40´Î
Êé½ÓÉϻأ¬Õâƪ½éÉÜÄǸöMContentHandlerµÄʵÏÖ£¬ÕâÊÇSAX½âÎö·½·¨µÄºËÐÄËùÔÚ¡£
ÏÈ¿´¿´ÎÒÒª½âÎöµÄXMLÎļþÈçÏÂËùʾ£¬ÆäʵºÜ¼òµ¥£¬ÒòΪËü³ýÁËEle ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ