Sample SaxContentHandlerImpl Code (Windows Embedded CE 6.0)
1/6/2010
The following code examples illustrate how to write a customized XML parser for CE MSXML. For more information on including these files while creating a SAX2 application, see Tutorial: JumpStart for Creating a SAX2 Application with C++.
Sample SaxContentHandlerImpl.h
// SAXContentHandlerImpl.h: interface for the SAXContentHandlerImpl class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SAXCONTENTHANDLERIMPL_H__517D91C0_0BCF_474D_A77C_10EE27231233__INCLUDED_)
#define AFX_SAXCONTENTHANDLERIMPL_H__517D91C0_0BCF_474D_A77C_10EE27231233__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class SAXContentHandlerImpl : public ISAXContentHandler
{
public:
SAXContentHandlerImpl();
virtual ~SAXContentHandlerImpl();
// This must be correctly implemented, if your handler must be a COM Object (in this example it does not).
long __stdcall QueryInterface(const struct _GUID &,void ** );
unsigned long __stdcall AddRef(void);
unsigned long __stdcall Release(void);
virtual HRESULT STDMETHODCALLTYPE putDocumentLocator(
/* [in] */ ISAXLocator __RPC_FAR *pLocator);
virtual HRESULT STDMETHODCALLTYPE startDocument( void);
virtual HRESULT STDMETHODCALLTYPE endDocument( void);
virtual HRESULT STDMETHODCALLTYPE startPrefixMapping(
/* [in] */ wchar_t __RPC_FAR *pwchPrefix,
/* [in] */ int cchPrefix,
/* [in] */ wchar_t __RPC_FAR *pwchUri,
/* [in] */ int cchUri);
virtual HRESULT STDMETHODCALLTYPE endPrefixMapping(
/* [in] */ wchar_t __RPC_FAR *pwchPrefix,
/* [in] */ int cchPrefix);
virtual HRESULT STDMETHODCALLTYPE startElement(
/* [in] */ wchar_t __RPC_FAR *pwchNamespaceUri,
/* [in] */ int cchNamespaceUri,
/* [in] */ wchar_t __RPC_FAR *pwchLocalName,
/* [in] */ int cchLocalName,
/* [in] */ wchar_t __RPC_FAR *pwchRawName,
/* [in] */ int cchRawName,
/* [in] */ ISAXAttributes __RPC_FAR *pAttributes);
virtual HRESULT STDMETHODCALLTYPE endElement(
/* [in] */ wchar_t __RPC_FAR *pwchNamespaceUri,
/* [in] */ int cchNamespaceUri,
/* [in] */ wchar_t __RPC_FAR *pwchLocalName,
/* [in] */ int cchLocalName,
/* [in] */ wchar_t __RPC_FAR *pwchRawName,
/* [in] */ int cchRawName);
virtual HRESULT STDMETHODCALLTYPE characters(
/* [in] */ wchar_t __RPC_FAR *pwchChars,
/* [in] */ int cchChars);
virtual HRESULT STDMETHODCALLTYPE ignorableWhitespace(
/* [in] */ wchar_t __RPC_FAR *pwchChars,
/* [in] */ int cchChars);
virtual HRESULT STDMETHODCALLTYPE processingInstruction(
/* [in] */ wchar_t __RPC_FAR *pwchTarget,
/* [in] */ int cchTarget,
/* [in] */ wchar_t __RPC_FAR *pwchData,
/* [in] */ int cchData);
virtual HRESULT STDMETHODCALLTYPE skippedEntity(
/* [in] */ wchar_t __RPC_FAR *pwchName,
/* [in] */ int cchName);
};
#endif // !defined(AFX_SAXCONTENTHANDLERIMPL_H__517D91C0_0BCF_474D_A77C_10EE27231233__INCLUDED_)
Sample SaxContentHandlerImpl.cpp
// SAXContentHandlerImpl.cpp: implementation of the SAXContentHandlerImpl class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SAXContentHandlerImpl.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SAXContentHandlerImpl::SAXContentHandlerImpl()
{
}
SAXContentHandlerImpl::~SAXContentHandlerImpl()
{
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::putDocumentLocator(
/* [in] */ ISAXLocator __RPC_FAR *pLocator
)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::startDocument()
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::endDocument( void)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::startPrefixMapping(
/* [in] */ wchar_t __RPC_FAR *pwchPrefix,
/* [in] */ int cchPrefix,
/* [in] */ wchar_t __RPC_FAR *pwchUri,
/* [in] */ int cchUri)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::endPrefixMapping(
/* [in] */ wchar_t __RPC_FAR *pwchPrefix,
/* [in] */ int cchPrefix)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::startElement(
/* [in] */ wchar_t __RPC_FAR *pwchNamespaceUri,
/* [in] */ int cchNamespaceUri,
/* [in] */ wchar_t __RPC_FAR *pwchLocalName,
/* [in] */ int cchLocalName,
/* [in] */ wchar_t __RPC_FAR *pwchRawName,
/* [in] */ int cchRawName,
/* [in] */ ISAXAttributes __RPC_FAR *pAttributes)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::endElement(
/* [in] */ wchar_t __RPC_FAR *pwchNamespaceUri,
/* [in] */ int cchNamespaceUri,
/* [in] */ wchar_t __RPC_FAR *pwchLocalName,
/* [in] */ int cchLocalName,
/* [in] */ wchar_t __RPC_FAR *pwchRawName,
/* [in] */ int cchRawName)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::characters(
/* [in] */ wchar_t __RPC_FAR *pwchChars,
/* [in] */ int cchChars)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::ignorableWhitespace(
/* [in] */ wchar_t __RPC_FAR *pwchChars,
/* [in] */ int cchChars)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::processingInstruction(
/* [in] */ wchar_t __RPC_FAR *pwchTarget,
/* [in] */ int cchTarget,
/* [in] */ wchar_t __RPC_FAR *pwchData,
/* [in] */ int cchData)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE SAXContentHandlerImpl::skippedEntity(
/* [in] */ wchar_t __RPC_FAR *pwchVal,
/* [in] */ int cchVal)
{
return S_OK;
}
long __stdcall SAXContentHandlerImpl::QueryInterface(const struct _GUID &riid,void ** ppvObject)
{
return 0;
}
unsigned long __stdcall SAXContentHandlerImpl::AddRef()
{
return 0;
}
unsigned long __stdcall SAXContentHandlerImpl::Release()
{
return 0;
}