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

📄 xmlparsemustsucappui.cpp

📁 Symbian下解析XML的代码,完全用API解析
💻 CPP
字号:
/*
============================================================================
 Name        : XMLParseMustSucAppUi.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Main application UI class (controller)
============================================================================
*/

// INCLUDE FILES
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <XMLParseMustSuc.rsg>
#include <f32file.h>
#include <s32file.h>

#include "XMLParseMustSuc.pan"
#include "XMLParseMustSucAppUi.h"
#include "XMLParseMustSucAppView.h"
#include "XMLParseMustSuc.hrh"

#include "MyContentHandler.h"

#include <xml\parser.h> // for CParser

//Constants
_LIT8( KXmlMimeType, "text/xml" );
_LIT( KFileName, "\\system\\apps\\MyXmlParser\\example.xml" );
_LIT8(KXMLString,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><note><elva>elva smile</elva><whh>whh</whh></note>");
// ============================ MEMBER FUNCTIONS ===============================


// -----------------------------------------------------------------------------
// CXMLParseMustSucAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CXMLParseMustSucAppUi::ConstructL()
    {
    // Initialise app UI with standard value.
    BaseConstructL();

    // Create view object
    iAppView = CXMLParseMustSucAppView::NewL( ClientRect() );
    }
// -----------------------------------------------------------------------------
// CXMLParseMustSucAppUi::CXMLParseMustSucAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CXMLParseMustSucAppUi::CXMLParseMustSucAppUi()
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CXMLParseMustSucAppUi::~CXMLParseMustSucAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CXMLParseMustSucAppUi::~CXMLParseMustSucAppUi()
    {
    if ( iAppView )
        {
        delete iAppView;
        iAppView = NULL;
        }

    }

// -----------------------------------------------------------------------------
// CXMLParseMustSucAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CXMLParseMustSucAppUi::HandleCommandL( TInt aCommand )
    {
    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;
        case EXMLParseMustSucCommand1:
            {
            //// Load a string from the resource file and display it
            //HBufC* textResource = StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT );
            //
            //// Show the information Note with
            //// textResource loaded with StringLoader.
            //CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
            //informationNote->ExecuteLD( *textResource );

            //// Pop HBuf from CleanUpStack and Destroy it.
            //CleanupStack::PopAndDestroy( textResource );
			CMyContentHandler * iCMyContentHandler = CMyContentHandler::NewL();
			CParser *iParser = CParser::NewL(KXmlMimeType,*iCMyContentHandler);

			//TFileName filename;
			//filename.Append(KFileName);

			///*RFs rfs;
			//RFs.Connect(KFileServerDefaultMessageSlots);*/

			//RFile file;

			//User::LeaveIfError( file.Open(CCoeEnv::Static()->FsSession(), filename,EFileRead ) );
			//CleanupClosePushL( file );

			//TInt size;
			//User::LeaveIfError( file.Size( size ) );

			//iBuffer = 0;
			//iBuffer = HBufC8::NewL( size );
			//TPtr8 bufferPtr( iBuffer->Des() );
			//User::LeaveIfError( file.Read( bufferPtr ) );

			//CleanupStack::PopAndDestroy(); // file

			// Now, we have the whole file content in iBuffer.
			// We are ready to parse the XML content.

			iParser->ParseBeginL();
			iParser->ParseL( KXMLString );

			// Since we read the whole file contents within one-shot,
			// we can call ParseEndL() right after calling ParseL().
			iParser->ParseEndL();

			delete iParser;

			delete iCMyContentHandler;
			break;
            }
            
        default:
            Panic( EXMLParseMustSucUi );
            break;
        }
    }
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CXMLParseMustSucAppUi::HandleStatusPaneSizeChange()
{
	iAppView->SetRect( ClientRect() );
	
} 


// End of File

⌨️ 快捷键说明

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