static _bstr_t checkParseError(MSXML2::IXMLDOMParseErrorPtr pError) { _bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline()) + _bstr_t("\n")+ _bstr_t(pError->Getreason()); //MessageBox(NULL,parseError, "Parse Error",MB_OK); return parseError; }
BOOL CIconImgList::LoadExtIconData( void) { // 通常アイコンの読み込み m_hBmpDefault = ::LoadBitmap( AfxGetResourceHandle(), MAKEINTRESOURCE( IDB_ICONIMG)); TCHAR szFilePath[ MAX_PATH]; int nLength = GetModuleFileName( NULL, szFilePath, MAX_PATH); for( int nIndex = nLength; nIndex >= 0; nIndex--) { if( TEXT( '\\') == szFilePath[ nIndex]) { lstrcpy( &szFilePath[ nIndex + 1], TEXT( "GetIcon.xml")); break; } } BOOL blResult = FALSE; MSXML2::IXMLDOMDocumentPtr piDocument; if( SUCCEEDED( piDocument.CreateInstance( _T( "Microsoft.XMLDOM")))) { piDocument->PutvalidateOnParse( VARIANT_TRUE); if( VARIANT_FALSE != piDocument->load( _variant_t( _bstr_t( szFilePath)))) { if( LoadIcons( piDocument)) { blResult = LoadGroups( piDocument); } } else { MSXML2::IXMLDOMParseErrorPtr piError; piError = piDocument->GetparseError(); long lCode = piError->GeterrorCode(); TRACE( _T( "0x%08X\n"), lCode); // 0x800C0005 if( NULL != piError && 0 != lCode && 0x800C0005/*INET_E_RESOURCE_NOT_FOUND*/ != lCode) { long lRaw = piError->Getline(); long lCol = piError->Getlinepos(); _bstr_t cBstr = piError->Getreason(); _bstr_t cBstrSrc = piError->GetsrcText(); CString cStr; cStr.Format( _T( "拡張アイコンデータファイルを解析できませんでした。\n%s\n\nソース:%s\n位置:%d行 %d文字"), ( ( char*)cBstr), ( ( char*)cBstrSrc), lRaw, lCol); MessageBox( NULL, cStr, NULL, MB_OK | MB_ICONEXCLAMATION); } } } return blResult; }
BOOL CVCAMetaParserMSXML::ParseMetaData( unsigned char *pMetadata, int nLength ) { CComBSTR sz( (char *)pMetadata ); VARIANT_BOOL vb; USES_CONVERSION; pMetadata[nLength] = '\0'; BSTR bstr = SysAllocString( A2W( (char *)pMetadata ) ); // sz = CComBSTR("<?xml version=\"1.0\"?>\n<vca>\n <vca_hdr>\n <frame_id>10</frame_id>\n </vca_hdr>\n</vca>\n"); // TRACE( (char *)pMetadata ); vb = m_pDOMDoc->loadXML( bstr); // FILE *pFile; // pFile = fopen( "C:\\vtmeta.txt", "a" ); // fwrite( pMetadata, strlen( (char *)pMetadata ), 1, pFile ); // fclose( pFile ); if( VARIANT_TRUE == vb ) { // Find the header ParseHeader(); ParseStab(); ParseObjects(); ParseEvents(); ParseCounts(); ParseBlobsImp(_XML_TAMPERMAP, &m_TamperInfo); ParseBlobsImp(_XML_SCENECHANGEMAP, &m_SceneChangeInfo); ParseBlobsImp(_XML_BLOBMAP, &m_BlobMap); ParseBlobsImp(_XML_STATBLOBMAP, &m_StationaryMap); ParseBlobsImp(_XML_SMOKEMAP,&m_SmokeMap); ParseBlobsImp(_XML_FIREMAP,&m_FireMap); ParseCE(); } else { // Loading the doc failed, find out why... MSXML2::IXMLDOMParseErrorPtr pErr = m_pDOMDoc->parseError; CString strLine, sResult; strLine.Format(_T(" ( line %u, column %u )"), pErr->Getline(), pErr->Getlinepos()); // Return validation results in message to the user. if (pErr->errorCode != S_OK) { sResult = CString("Validation failed on ") + CString ("\n=====================") + CString("\nReason: ") + CString( (char*)(pErr->Getreason())) + CString("\nSource: ") + CString( (char*)(pErr->GetsrcText())) + strLine + CString("\n"); ATLTRACE(sResult); // AfxMessageBox( (char *)pMetadata ); } } // memset( pMetadata, NULL, 2048 ); SysFreeString( bstr ); return TRUE; }
BOOL CoExtender::ParseSettings() { BOOL bOk = FALSE; VARIANT_BOOL vb; USES_CONVERSION; struct _stat64i32 statInfo; if( 0 == _tstat( SETTINGS_FILE, &statInfo ) ) { vb = m_pDOMDoc->load( SETTINGS_FILE ); } else { CString s; s.Format( _T("Unable to load settings file: %s"), SETTINGS_FILE ); AfxMessageBox( s ); return FALSE; } if( VARIANT_TRUE == vb ) { // Parse config file location MSXML2::IXMLDOMNodePtr pNode, pSubNode; BSTR bsTag = CComBSTR( "root/config_file" ); pNode = m_pDOMDoc->selectSingleNode( (BSTR) bsTag ); if( pNode ) { m_sConfigFile = (char *)pNode->text; } else { AfxMessageBox( _T("Config file not specified in extender config XML file") ); } // Video settings bsTag = CComBSTR( "root/video_src" ); pNode = m_pDOMDoc->selectSingleNode( (BSTR) bsTag ); if( pNode ) { bsTag = CComBSTR( "type" ); pSubNode = pNode->selectSingleNode( (BSTR) bsTag ); if( pSubNode ) { if( 0 == strcmp( pSubNode->text, "dshow" ) ) m_eVideoType = VIDEO_DSHOW; else if( 0 == strcmp( pSubNode->text, "vlc" ) ) m_eVideoType = VIDEO_VLC; else if( 0 == strcmp( pSubNode->text, "cap5" ) )m_eVideoType = VIDEO_CAP5; else m_eVideoType = VIDEO_NULL; } bsTag = CComBSTR( "data" ); pSubNode = pNode->selectSingleNode( (BSTR) bsTag ); if( pSubNode ) { m_sVideoData = (char *) pSubNode->text; } bsTag = CComBSTR( "stream_video" ); pSubNode = pNode->selectSingleNode( (BSTR) bsTag ); if( pSubNode ) { int i = atoi( pSubNode->text ); m_bVideo = i > 0 ? TRUE : FALSE; } bsTag = CComBSTR( "stream_meta" ); pSubNode = pNode->selectSingleNode( (BSTR) bsTag ); if( pSubNode ) { int i = atoi( pSubNode->text ); m_bMeta = i > 0 ? TRUE : FALSE; } } // local VCA settings bsTag = CComBSTR( "root/local_vca" ); pNode = m_pDOMDoc->selectSingleNode( (BSTR) bsTag ); if( pNode ) { bsTag = CComBSTR( "license" ); pSubNode = pNode->selectSingleNode( (BSTR) bsTag ); if( pSubNode ) { strcpy_s( m_sLicense, _countof( m_sLicense ), T2A( pSubNode->text ) ); } } bOk = TRUE; } else { // Loading the doc failed, find out why... MSXML2::IXMLDOMParseErrorPtr pErr = m_pDOMDoc->parseError; CString strLine, sResult; strLine.Format(_T(" ( line %u, column %u )"), pErr->Getline(), pErr->Getlinepos()); // Return validation results in message to the user. if (pErr->errorCode != S_OK) { sResult = CString("Validation failed on ") + CString ("\n=====================") + CString("\nReason: ") + CString( (char*)(pErr->Getreason())) + CString("\nSource: ") + CString( (char*)(pErr->GetsrcText())) + strLine + CString("\n"); ATLTRACE(sResult); AfxMessageBox( sResult ); } } return bOk; }