When it comes to using the Simple API for XML (SAX2), the most useful handler class is the ContentHandler. You derive this class from the ISAXContentHandler interface.
To use the SAX2 interfaces in Microsoft® XML Core Services (MSXML), you must declare them with the following code. The following shows importing msxml4.dll.
#import <msxml4.dll> raw_interfaces_only using namespace MSXML2;
Note For the JumpStart application, you declare the interfaces in the StdAfx.h file.
To implement the ContentHandler, create the header file, named "MyContent.h", as shown in the following sample code.
#if !defined(AFX_MYCONTENT_H__E1B3AF99_0FA6_44CD_82E3_55719F9E3806__INCLUDED_)
#define AFX_MYCONTENT_H__E1B3AF99_0FA6_44CD_82E3_55719F9E3806__INCLUDED_
#include "SAXContentHandlerImpl.h"
class MyContent : public SAXContentHandlerImpl
{
public:
MyContent();
virtual ~MyContent();
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 *pwchQName,
/* [in] */ int cchQName,
/* [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 *pwchQName,
/* [in] */ int cchQName);
virtual HRESULT STDMETHODCALLTYPE startDocument();
private:
void prt(
/* [in] */ const wchar_t * pwchFmt,
/* [in] */ const wchar_t __RPC_FAR *pwchVal,
/* [in] */ int cchVal);
int idnt;
};
#endif
//!defined(AFX_MYCONTENT_H__E1B3AF99_0FA6_44CD_82E3_55719F9E3806__INCLUDED_)
| This HTML Help has been published using the chm2web software. |