⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlhandler.h

📁 手机天气预报系统
💻 H
字号:
/*
 ============================================================================
 Name		: XmlHandler.h
 Author	  : Richie Chyi
 Copyright   : Copyright?2008
 Description : Parse Xml buffer from web.
 ============================================================================
 */

#ifndef __XMLHANDLER_H__
#define __XMLHANDLER_H__
 
// INCLUDE FILES
#include <e32base.h>
#include <xml\contenthandler.h> // for MContentHandler
#include <xml\parser.h> // for CParser

#include "WeatherDetail.h"
 
// CONSTANTS
_LIT8(KElementRoot, "xml_api_reply");
_LIT8(KElementForecast,"forecast_conditions");

_LIT8(KElementDayOfWeak, "day_of_week");
_LIT8(KElementLow, "low");
_LIT8(KElementHigh, "high");
_LIT8(KElementIcon, "icon");
_LIT8(KElementCondition, "condition");

// CLASS DECLARATION
 
using namespace Xml;

class MXmlParseObserver
	{
public:
	virtual void ParseCompleted() = 0;
	};
 
class CXmlHandler: public MContentHandler
    {
 
public: // Constructors and destructor
    
    static CXmlHandler* NewL(RArray<TWeatherDetail>& aDetails, MXmlParseObserver& aObserver);
    
    static CXmlHandler* NewLC(RArray<TWeatherDetail>& aDetails, MXmlParseObserver& aObserver);
    
    virtual ~CXmlHandler();
    
public: // Public methods
 
    void StartParsingL( const TDesC& aBuffer );
    
    inline RArray<TWeatherDetail>& DetailsArray();
    
private: // Constructors
 
    CXmlHandler(RArray<TWeatherDetail>& aDetails, MXmlParseObserver& aObserver);
    
    void ConstructL();
    
private: // from MContentHandler
 
    void OnStartDocumentL( const RDocumentParameters &aDocParam,
        TInt aErrorCode );
    
    void OnEndDocumentL( TInt aErrorCode );
    
    void OnStartElementL( const RTagInfo &aElement,
        const RAttributeArray &aAttributes, TInt aErrorCode );
        
    void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode );
    
    void OnContentL( const TDesC8 &aBytes, TInt aErrorCode );
    
    void OnStartPrefixMappingL( const RString &aPrefix, const RString &aUri,
        TInt aErrorCode );
        
    void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode );
    
    void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode );
    
    void OnSkippedEntityL( const RString &aName, TInt aErrorCode );
    
    void OnProcessingInstructionL( const TDesC8 &aTarget, const TDesC8 &aData,
        TInt aErrorCode);
        
    void OnError( TInt aErrorCode );
    
    TAny *GetExtendedInterface( const TInt32 aUid );
    
private: // Private data
 
    CParser* iParser;
    HBufC8* iBuffer;
    
    MXmlParseObserver& iObserver;
 
    RArray<TWeatherDetail>& iWeatherDetails;
    TBool iHasNewElement;
    };
#endif /* __XMLHANDLER_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -