hero_xmlContentHandler.cpp
资源名称:xml_Vc.zip [点击查看]
上传用户:quanyou
上传日期:2022-06-07
资源大小:39k
文件大小:3k
源码类别:
xml/soap/webservice
开发平台:
Visual C++
- // HERO_XMLContentHandler.cpp: derived class from SAXContentHandlerImpl
- #include "stdafx.h"
- #include "HERO_XMLContentHandler.h"
- #include <wchar.h>
- #include "Test_Sax.h"
- #include "Test_SaxDlg.h"
- //HTREEITEM ht[12];
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- //CListBox* list_m;
- HERO_XMLContentHandler::HERO_XMLContentHandler()
- {
- _wsetlocale(0,L"chs");
- idnt = 0;
- i=0;
- k=0;
- }
- HERO_XMLContentHandler::~HERO_XMLContentHandler()
- {
- //object destruction is handled by the Release() impl of parent class
- }
- //hides the new operator
- HERO_XMLContentHandler * HERO_XMLContentHandler::CreateInstance()
- {
- HERO_XMLContentHandler * pHERO_XMLContentHandler = NULL;
- pHERO_XMLContentHandler = new HERO_XMLContentHandler();
- assert(pHERO_XMLContentHandler!=NULL);
- return pHERO_XMLContentHandler;
- }
- HRESULT STDMETHODCALLTYPE HERO_XMLContentHandler::startDocument( void)
- {
- return S_OK;
- // return E_FAIL; //The parse operation should be aborted.
- }
- HRESULT STDMETHODCALLTYPE HERO_XMLContentHandler::endDocument( void)
- {
- return S_OK;
- // return E_FAIL; //The parse operation should be aborted.
- }
- HRESULT STDMETHODCALLTYPE HERO_XMLContentHandler::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)
- {
- m_bflag=0;
- // A little example, how to abort parse
- if ( wcsncmp(pwchLocalName,L"name",4) == 0 ) {
- m_bflag=1;
- }
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE HERO_XMLContentHandler::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;
- // return E_FAIL; //The parse operation should be aborted.
- }
- HRESULT STDMETHODCALLTYPE HERO_XMLContentHandler::characters(
- /* [in] */ wchar_t __RPC_FAR *pwchChars,
- /* [in] */ int cchChars)
- {
- static wchar_t val[1000];
- CTest_SaxDlg *pdlg=(CTest_SaxDlg *)AfxGetMainWnd();
- cchChars = cchChars>999 ? 999 : cchChars;
- wcsncpy( val, pwchChars, cchChars );
- val[cchChars] = 0;
- CString str2;
- for(int j=0;j<cchChars;j++)
- if(val[j]<32)
- return S_OK;
- wcstombs(str2.GetBufferSetLength(1000),val,1000);
- if(!str2.IsEmpty())
- if(m_bflag)
- {SetWindowText(GetDlgItem(pdlg->m_hWnd,IDC_HERO1+i),str2);i++;}
- else
- {SetWindowText(GetDlgItem(pdlg->m_hWnd,IDC_HERO11+k),str2); k++;}
- str2.ReleaseBuffer();
- return S_OK;
- // return E_FAIL; //The parse operation should be aborted.
- }