BOOL APBuf::setBuffer(BSTR str, MSXML2::IXMLDOMDocumentPtr & xml)
{
	
	xml.CreateInstance(_T("Msxml2.DOMDocument"));
	xml->async = VARIANT_FALSE; // default - true,
	//vytvoreni XML DOM z nacteneho XML stringu

	CDirectoriesManager & m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->DirectoriesManager;
	CString str_b = str;
	CFile f;
	f.Open(m.getXMLFilesDirectory() + "\\plug_out_example1.xml", CFile::modeWrite |CFile::modeCreate);
	f.Write((LPCTSTR) str_b, str_b.GetLength());
	f.Close();


	HRESULT hRes=xml->loadXML(str);
	if (xml->parseError->errorCode != S_OK)
	{
		if ((str == NULL) || (* str == 0)) return FALSE;

		CReportAsistentApp::ReportError(IDS_SIMPLE_FILTER_FAILED_SOURCE_LOAD, (LPCTSTR) xml->parseError->reason);

		xml.Release();
		xml = NULL;	

		return FALSE;
	}

	return TRUE;
}
Exemplo n.º 2
0
BOOL WXmlParse::readObject(std::vector<ExternalObject *> &objTree)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  递归获取对象树
	elementNodes->get_item(3, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		ExternalObject *objTmp = new ExternalObject();
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		readObject(objTmp, xmlSubNode);
		objTree.push_back(objTmp);
	}

	return TRUE;
}
Exemplo n.º 3
0
/******************************************************************************
Function Name  :  nParseTSFile
Input(s)       :  CString omstrTSFile
Output         :  INT
Functionality  :  Load the omStrTSFille
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
Codetag        : CS002
******************************************************************************/
INT CTestSetupEntity::nParseTSFile(CString omstrTSFile)
{
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    if ( FAILED(hr) )
    {
        throw "Unable to create XML parser object";
    }

    if(PathFileExists(omstrTSFile) == FALSE)
    {
        return ERR_PATH_INCORRECT;
    }

    //Create A TestSetup DOM document
    CComVariant varFileName((LPCSTR)omstrTSFile);

    try
    {
        pIDOMDoc->load(varFileName);
        //GetTest Setup Title
        MSXML2::IXMLDOMNodePtr pIDOMTiltleNode;
        _bstr_t bstrNodeName = def_STR_TSNODE_NAME;
        CComVariant NodeValue;
        pIDOMTiltleNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        MSXML2::IXMLDOMNamedNodeMapPtr pDOMTCAtrributes;
        pDOMTCAtrributes = pIDOMTiltleNode->Getattributes();
        MSXML2::IXMLDOMNodePtr pIDOMChildNode;
        //bstrNodeName = def_STR_TSATTRIB_TITLE;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSATTRIB_TITLE)));
        pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
        pIDOMChildNode->get_nodeTypedValue(&NodeValue);
        m_omstrTestSetupTitle = strCopyBSTRToCString(NodeValue);
        pIDOMChildNode.Release();
        //Get Description
        //bstrNodeName = def_STR_TSDESCRIPTION;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSDESCRIPTION)));
        MSXML2::IXMLDOMNodePtr pIDOMDescriptionNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        pIDOMDescriptionNode->get_nodeTypedValue(&NodeValue);
        m_omstrDescription = strCopyBSTRToCString(NodeValue);
        //Get Header Node
        //bstrNodeName = def_STR_TSHEADER;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSHEADER)));
        MSXML2::IXMLDOMNodePtr pIDOMHeaderNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        nLoadHeader(pIDOMHeaderNode);
        pIDOMHeaderNode.Release();
        //Get TestCases List
        //bstrNodeName = def_STR_TSTCLIST;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSTCLIST)));
        MSXML2::IXMLDOMNodePtr pIDOMTSNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        GetData(pIDOMTSNode);
    }
    catch(...)
    {
        return S_FALSE;
    }

    return S_OK;
}
Exemplo n.º 4
0
BOOL WXmlParse::readExtendModName(std::vector<std::pair<string, string> > &modNames)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  扩展模块列表
	elementNodes->get_item(1, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		MSXML2::IXMLDOMNodePtr nameNode = elementAttributes->getNamedItem("name");
		MSXML2::IXMLDOMNodePtr descNode = elementAttributes->getNamedItem("description");
		modNames.push_back(std::make_pair(nameNode->text, descNode->text));
	}

	return TRUE;
}
Exemplo n.º 5
0
/*
 * Private method that loads XML into an MSXML DomDocument object and passes
 * this object to the event handler.
 */
bool XMPPXMLParser::NotifyHandler(const UTF32String& stanzaName)
{
	bool continueParsing;

	FixXMLNS();

	MSXML2::IXMLDOMDocumentPtr xmlDoc;
	xmlDoc.CreateInstance(CLSID_DOMDocument);
	BOOL bSuccess = xmlDoc->loadXML(
		_bstr_t(UTF::utf32to16(m_ParsedData).c_str()));

	if(bSuccess)
	{
		m_Handlers.OnStanza(
			xmlDoc, _bstr_t(UTF::utf32to16(stanzaName).c_str()));
		continueParsing = true;
	}
	else
	{
		m_Logger.LogLoadXMLError(xmlDoc, UTF::utf32to16(m_ParsedData));
		continueParsing = false;
	}

	return continueParsing;
}
Exemplo n.º 6
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomVerifyNode
Output         :  HRESULT
Functionality  :  Creates the XML file with pIDomVerifyNode
Member of      :  CVerify_MessageEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam, GT-Derka
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerify_MessageEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomVerifyNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    MSXML2::IXMLDOMElementPtr pChildElement, pSubElement;

    if (pIDOMDoc != nullptr)
    {
        pChildElement   =  pIDOMDoc->createElement(_bstr_t(_(def_STR_VERIFYMSG_NODE)));

        MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_ID);
        if(pIDomTSAtrrib!= nullptr)
        {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_dwMessageID);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        pIDomTSAtrrib = pIDOMDoc->createAttribute(_(def_STR_TCATTRIB_UNIT));
        if(pIDomTSAtrrib!= nullptr)
        {
            switch(m_ouData.m_eSignalUnitType)
            {
                case ENG:
                    omstrTemp = "ENG";
                    break;
                default:
                case RAW:
                    omstrTemp = "RAW";
                    break;
            }
            pIDomTSAtrrib->value = _bstr_t(omstrTemp);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_CHANNEL);
        if(pIDomTSAtrrib!= NULL)
        {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_byChannelNumber);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        INT lCount = (INT)m_ouData.m_odSignalConditionList.GetCount();
        for(INT i =0; i<lCount; i++)
        {
            POSITION pos = m_ouData.m_odSignalConditionList.FindIndex(i);
            CSignalCondition& ouSignalData = m_ouData.m_odSignalConditionList.GetAt(pos);
            pSubElement   =  pIDOMDoc->createElement(_bstr_t(_(def_STR_SIGNAL_NODE)));
            pIDomTSAtrrib = pIDOMDoc->createAttribute(_(def_NAME_NODE));
            pIDomTSAtrrib->value = _bstr_t(ouSignalData.m_omSigName);
            pSubElement->setAttributeNode(pIDomTSAtrrib);
            pSubElement->Puttext(_bstr_t(ouSignalData.m_omCondition));
            pChildElement->appendChild(pSubElement);
        }
        pIDomVerifyNode->appendChild(pChildElement);
    }
    return S_OK;
}
Exemplo n.º 7
0
MSXML2::IXMLDOMDocumentPtr CyDoc::GetDocument()
{
	MSXML2::IXMLDOMDocumentPtr spDoc;
	spDoc.CreateInstance(__uuidof(MSXML2::DOMDocument));
	spDoc->async = VARIANT_FALSE;
	spDoc->preserveWhiteSpace = VARIANT_TRUE;
	spDoc->resolveExternals = VARIANT_FALSE;
	return spDoc;
}
Exemplo n.º 8
0
/******************************************************************************
Function Name  :  SaveFileAs
Input(s)       :  CString omFilePath
Output         :  HRESULT
Functionality  :
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
Codetag        :  CS006
******************************************************************************/
HRESULT CTestSetupEntity::SaveFileAs(CString omFilePath)
{
    if(omFilePath.IsEmpty() == TRUE)
    {
        return S_FALSE;
    }

    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;

    HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    if ( FAILED(hr) )
    {
        return S_FALSE;
    }


    MSXML2::IXMLDOMProcessingInstructionPtr pIDomPi;
    pIDomPi = pIDOMDoc->createProcessingInstruction(def_DOM_INSTRUCTION);
    VARIANT_BOOL b = TRUE;
    pIDOMDoc->put_preserveWhiteSpace(b);

    if (pIDomPi != nullptr)
    {
        pIDOMDoc->appendChild(pIDomPi);
    }

    //testSETUP Node <testsetup>
    MSXML2::IXMLDOMElementPtr pIDomTSNode = pIDOMDoc->createElement(_bstr_t(def_STR_TSNODE_NAME));
    pIDOMDoc->appendChild(pIDomTSNode);

    //Title Attribute <testsetup title = "">
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TSATTRIB_TITLE);
    if(pIDomTSAtrrib!= nullptr)
    {
        pIDomTSAtrrib->value = _bstr_t(m_omstrTestSetupTitle);
        pIDomTSNode->setAttributeNode(pIDomTSAtrrib);
    }

    //Descriprion Node <testsetup title = ""><description>
    MSXML2::IXMLDOMElementPtr pIDomDescriptionNode = pIDOMDoc->createElement(_bstr_t(def_STR_DESC_NODE));
    pIDomDescriptionNode->Puttext(_bstr_t(m_omstrDescription));
    pIDomTSNode->appendChild(pIDomDescriptionNode);

    //Heade Node
    MSXML2::IXMLDOMElementPtr pIDomHeaderNode = pIDOMDoc->createElement(_bstr_t(def_STR_HEADER_NAME));
    nSaveHeader(pIDomHeaderNode, omFilePath);
    pIDomTSNode->appendChild(pIDomHeaderNode);

    //TestCase List
    MSXML2::IXMLDOMElementPtr pIDomTestCaseNode = pIDOMDoc->createElement(_bstr_t(def_STR_TCLIST_NODE));
    SetData(pIDomTestCaseNode);
    pIDomTSNode->appendChild(pIDomTestCaseNode);
    FormatDOMDocument(pIDOMDoc, omFilePath);
    return S_OK;
}
Exemplo n.º 9
0
	MSXML2::IXMLDOMDocument* CXmlDocumentWrapper::Clone()
	{
		if (!IsValid())
			return NULL;
		MSXML2::IXMLDOMDocumentPtr xmldoc;
		xmldoc.CreateInstance(MSXML2::CLSID_DOMDocument);
		_variant_t v(xmldoc.GetInterfacePtr());
		m_xmldoc->save(v);
		return xmldoc.Detach();
	}
Exemplo n.º 10
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyResponse
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyResponse::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    INT lCount = (INT)m_ouData.m_odVerify_MessageEntityList.GetCount();
    MSXML2::IXMLDOMElementPtr pIDomSendNode =  pIDOMDoc->createElement(_bstr_t(def_STR_VERIFYRES_NODE));
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_ATTRIB_FAIL);

    if(pIDomTSAtrrib!= NULL)
    {
        switch(m_ouData.m_eAttributeError)
        {
            case SUCCESS:
                omstrTemp = "SUCCESS";
                break;

            case WARNING:
                omstrTemp = "WARNING";
                break;

            case FATAL:
                omstrTemp = "FATAL";
                break;

            case ERRORS:
            default:
                omstrTemp = "ERRORS";
                break;
        }

        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
        pIDomSendNode->setAttributeNode(pIDomTSAtrrib);
    }

    MSXML2::IXMLDOMAttributePtr pIDomTSAtrribWait = pIDOMDoc->createAttribute(def_STR_ATTRIB_WAITFOR);

    if(pIDomTSAtrribWait!= NULL)
    {
        CString omstrWaitFor;
        omstrWaitFor.Format("%d", m_ushDuration);
        pIDomTSAtrribWait->value = _bstr_t(omstrWaitFor);
        pIDomSendNode->setAttributeNode(pIDomTSAtrribWait);
    }

    for(INT i=0; i<lCount; i++)
    {
        POSITION pos = m_ouData.m_odVerify_MessageEntityList.FindIndex(i);
        CVerify_MessageEntity& ouVerifyMsgEntity = m_ouData.m_odVerify_MessageEntityList.GetAt(pos);
        ouVerifyMsgEntity.SetData(pIDomSendNode);
    }

    pIDomTestCaseNode->appendChild(pIDomSendNode);
    return S_OK;
}
Exemplo n.º 11
0
BOOL WXmlParse::readCalculateParams(WCalcaulateParam &calParam)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
		return FALSE;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(2, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		MSXML2::IXMLDOMNodeListPtr subAttrNodes; 
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
//		ASSERT(attrLength == 2);

		MSXML2::IXMLDOMNodePtr descNode;
		MSXML2::IXMLDOMNodePtr stateNode;
		subAttrNodes->get_item(0, &descNode);
		subAttrNodes->get_item(1, &stateNode);
		std::vector<string> vecParam;
		string descText = descNode->text;
		string stateText = stateNode->text;
		vecParam.push_back(proName);
		vecParam.push_back(descText);
		vecParam.push_back(stateText);

		calParam.addParam(vecParam);
	}

	return TRUE;
}
// loads lists of Word styles from configuration XML file
BOOL CWordManager::loadStylesFromXML(LPCTSTR XMLFilePath)
{
	BOOL result = FALSE;	// return value
	CString FName;	// jmeno (cesta) ke konfig. souboru
	FName = XMLFilePath;

	MSXML2::IXMLDOMDocumentPtr pXMLDom;  // koren XML stromu
	MSXML2::IXMLDOMElementPtr pNode;	// korenovy element
	MSXML2::IXMLDOMNodeListPtr pChildren;  // seznam podelementu korenoveho elementu
	MSXML2::IXMLDOMNodeListPtr pChildrenItems;  // seznam podelementu elementu - vstupuje do funkce pro nacitani StringTable
	MSXML2::IXMLDOMElementPtr pChild;	//  podelement korenoveho elementu

	int i = 0;	// indexova promenna
	_variant_t  Atr_val;	// textova hodnota atributu
	HRESULT hr;
    
      //Vytvori COM objekt (resp. instanci objektu)
    hr = pXMLDom.CreateInstance(_T("Msxml2.DOMDocument"));
    if (FAILED(hr)) 
       return FALSE;
    pXMLDom->async = VARIANT_FALSE;
   
       //nacti DOM ze souboru
    if ( pXMLDom->load((LPCTSTR) FName) == VARIANT_TRUE)
	{
		pNode = pXMLDom->GetdocumentElement();
		if (pNode != NULL)
		{
			if (pNode->baseName == (_bstr_t) "word_styles") // spravny nazev korenoveho elementu
			{
				pChildren = pNode->childNodes;	// ziskani seznamu potomku
				pChild = NULL;
				while((pChild = pChildren->nextNode()) != NULL)  // zpracovavaji se potomci
				{
					pChildrenItems = pChild->childNodes;
					if (pChild->baseName == (_bstr_t) "templates")
						m_WordTemplates.loadItemsFromXML(pChildrenItems);

					else if (pChild->baseName == (_bstr_t) "paragraph_styles")
						m_WordParagraphStyles.loadItemsFromXML(pChildrenItems);

					else if (pChild->baseName == (_bstr_t) "character_styles")
						m_WordCharacterStyles.loadItemsFromXML(pChildrenItems);
					
				}
				result = TRUE;
			}
		}
	}

	pXMLDom.Release();

	return result;
}
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CReplayEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CReplayEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    if (pIDOMDoc != NULL)
    {
        MSXML2::IXMLDOMElementPtr pIDomWaitNode =  pIDOMDoc->createElement(_bstr_t(def_STR_REPLAY_NODE));
        pIDomWaitNode->Puttext(_bstr_t(m_omFilePath));
        pIDomTestCaseNode->appendChild(pIDomWaitNode);
    }
    return S_OK;
}
// saves a list of Word styles to configutation XML file
BOOL CWordManager::saveStylesToXML(LPCTSTR file_path)
{
	CString XMLString = "";
	XMLString += "<word_styles>";
		XMLString += "<templates>";
			XMLString += m_WordTemplates.getItemsInXML();
		XMLString += "</templates>";

		XMLString += "<paragraph_styles>";
			XMLString += m_WordParagraphStyles.getItemsInXML();
		XMLString += "</paragraph_styles>";

		XMLString += "<character_styles>";
			XMLString += m_WordCharacterStyles.getItemsInXML();
		XMLString += "</character_styles>";
	XMLString += "</word_styles>";

	CString FName;	// jmeno (cesta) ke konfig. souboru
	FName = file_path;

	MSXML2::IXMLDOMDocumentPtr pXMLDom;  // koren XML stromu
	HRESULT hr;
    
      //Vytvori COM objekt (resp. instanci objektu)
    hr = pXMLDom.CreateInstance(_T("Msxml2.DOMDocument"));
    if (FAILED(hr)) 
       return FALSE;
    pXMLDom->async = VARIANT_FALSE;
   
       //nacti DOM ze stringu
    if ( pXMLDom->loadXML((_bstr_t) XMLString) != VARIANT_TRUE)
	{
		pXMLDom.Release();
		return FALSE;
	}
	
	BOOL ret = FALSE;

	try
	{
		ret = S_OK == pXMLDom->save((LPCTSTR) FName);
	}
	catch(...)
	{
		ret = FALSE;
	}
	
	pXMLDom.Release();

	return ret;
}
Exemplo n.º 16
0
BOOL WXmlParse::readParam(std::vector<WParamDefine *> &outParams)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
		return FALSE;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(0, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		WParamDefine *paramTest = new WParamDefine(proName);
		MSXML2::IXMLDOMNodeListPtr subAttrNodes;  
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
		for (int k = 0;k < attrLength;k++)
		{
			subAttrNodes->get_item(k, &xmlAttrNode);
			string attrName = xmlAttrNode->nodeName;
			string attrText = xmlAttrNode->text;
			paramTest->addValue(attrName, attrText);
		}
		outParams.push_back(paramTest);
	}

	return TRUE;
}
Exemplo n.º 17
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CTestCaseEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CTestCaseEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_ID);
    if(pIDomTSAtrrib!= NULL)
	{
        pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omID);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_TITLE);
    if(pIDomTSAtrrib!= NULL)
	{
        pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omTitle);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_H_EXP);
    if(pIDomTSAtrrib!= NULL)
	{
        switch(m_ouData.m_eExcpAction)
        {
            case EXIT:
                omstrTemp = "EXIT";
                break;
            case CONTINUE:
            default:
                omstrTemp = "CONTINUE";
                break;
        }
        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    INT lCount = (INT)m_ouData.m_odTAEntityList.GetCount();
    for(int i=0; i<lCount;i++)
    {
        POSITION pos = m_ouData.m_odTAEntityList.FindIndex(i);
        CBaseEntityTA* pEntity = m_ouData.m_odTAEntityList.GetAt(pos);
        pEntity->SetData(pIDomTestCaseNode);
    }
    
    
    return 0;
}
Exemplo n.º 18
0
// 向CAD窗口发送命令
void  SendMessageToCad(CString& strCommand, CStringArray& strParamArray)
{
	MSXML2::IXMLDOMDocumentPtr lpDocument;
	long hr = lpDocument.CreateInstance(__uuidof(DOMDocument));

	if ( FAILED(hr) ) 
		_com_raise_error(hr);

	MSXML2::IXMLDOMProcessingInstructionPtr lpInstruction = lpDocument->createProcessingInstruction("xml","version='1.0' encoding='GB2312'");
	lpDocument->appendChild(lpInstruction);

	MSXML2::IXMLDOMElementPtr lpRoot = lpDocument->createElement(LPCTSTR("root"));

	lpDocument->appendChild(lpRoot);

	// 数据类型:命令或数据
	MSXML2::IXMLDOMElementPtr lpCommand = lpDocument->createElement("command");

	lpCommand->setAttribute("name", _variant_t(strCommand));

	lpRoot->appendChild(lpCommand);

	// 参数列表
	for (int i=0; i<strParamArray.GetSize(); i++)
	{
		CString strParam = strParamArray.GetAt(i);
		CString strName = strParam.Left(strParam.Find('='));
		CString strValue = strParam.Right(strParam.GetLength()-strParam.Find('=')-1);

		MSXML2::IXMLDOMElementPtr lpParam = lpDocument->createElement("param");
		lpParam->setAttribute("name", _variant_t(strName));
		lpParam->setAttribute("value", _variant_t(strValue));

		lpCommand->appendChild(lpParam);
	}

	CString strXML = (LPCTSTR)(lpDocument->xml);
	//	OutputDebugString(lpDocument->xml);

	COPYDATASTRUCT cds;
	cds.dwData = 0;
	cds.cbData = strXML.GetLength()+1;
	cds.lpData = (void*)strXML.GetBuffer(0);
	strXML.ReleaseBuffer();
	::SendMessage(acedGetAcadFrame()->m_hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
Exemplo n.º 19
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :  Creates the Xml Document 
Member of      :  CSendEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CSendEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    
    INT nCount = (INT)m_ouData.m_odSend_MessageDataList.GetCount();
    MSXML2::IXMLDOMElementPtr pIDomSendNode =  pIDOMDoc->createElement(_bstr_t(def_STR_SEND_NODE));
    for(INT i=0; i<nCount; i++)
    {
        POSITION pos = m_ouData.m_odSend_MessageDataList.FindIndex(i);
        CSend_MessageEntity& ouSendMsgEntity = m_ouData.m_odSend_MessageDataList.GetAt(pos);
        ouSendMsgEntity.SetData(pIDomSendNode);
    }
    pIDomTestCaseNode->appendChild(pIDomSendNode);
    return S_OK;
}
Exemplo n.º 20
0
/******************************************************************************
Function Name  :  nSaveTestCases
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  INT
Functionality  :   
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
INT CTestSetupEntity::nSaveTestCases(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    
    INT lCount = (INT)m_odTestCaseEntityList.GetCount();
    for(int i=0; i<lCount;i++)
    {
        MSXML2::IXMLDOMElementPtr pChildElement = pIDOMDoc->createElement(_bstr_t(def_STR_TESTCASE_NODE));
        POSITION pos = m_odTestCaseEntityList.FindIndex(i);
        CTestCaseEntity &odTestCaseEntity = m_odTestCaseEntityList.GetAt(pos);
        odTestCaseEntity.SetData(pChildElement);
        pIDomTestCaseNode->appendChild(pChildElement);
    }
    return S_OK;
}
Exemplo n.º 21
0
//装入项目
void CUpdateBuilderDlg::OnBnClickedLoadItem()
{
	CFileDialog dlg(TRUE, _T("*.xml"), _T("update.xml"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("XML File(*.xml)|*.xml||"));
	if (dlg.DoModal() == IDOK)
	{
		HRESULT hr = S_OK;
		MSXML2::IXMLDOMDocumentPtr	pXmlDoc;
		MSXML2::IXMLDOMNodeListPtr pNodeList;
		MSXML2::IXMLDOMElementPtr pElement;

		try
		{
			hr = pXmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
			if( FAILED( hr ) ) 
				_com_issue_error(hr);

			pXmlDoc->load(CComVariant(dlg.GetPathName()));
			
			pNodeList = pXmlDoc->selectNodes("/manifest/filelist/file");
			
			m_FileListCtrl.DeleteAllItems();
			LONG lItemCount = pNodeList->Getlength();
			int nItem; 

			for (LONG lIndex = 0; lIndex < lItemCount; lIndex++)
			{
				pElement = pNodeList->Getitem(lIndex);
				nItem = m_FileListCtrl.InsertItem(0, CString(pElement->getAttribute("filename")));
				m_FileListCtrl.SetItemText(nItem, 1, CString(pElement->getAttribute("filesize")));
				m_FileListCtrl.SetItemText(nItem, 2, CString(pElement->getAttribute("fileversion")));
				m_FileListCtrl.SetItemText(nItem, 3, CString(pElement->getAttribute("md5")));
				m_FileListCtrl.SetItemData(nItem, (ULONG)pElement->getAttribute("filesize"));
			}

			SetWindowText(dlg.GetPathName());
			GetDlgItem(IDC_UPDATE_ITEM)->EnableWindow(TRUE);
		}
		catch(_com_error& e)
		{
			CString strError;
			strError.Format(_T("Error code:%d\nError Message:%s\nError Description:%s"), 
				(int)e.WCode(), e.ErrorMessage(), (char*)e.Description());
			MessageBox(strError, _T("错误"),MB_OK|MB_ICONSTOP);
		}
	}
}
Exemplo n.º 22
0
MSXML2::IXMLDOMDocumentPtr
CREBUS::getPluginParmsDef(_bstr_t coclass)
{
	PluginTypeLib::PluginPtr plugin;
	plugin.CreateInstance((char *) coclass);

	MSXML2::IXMLDOMDocumentPtr xml;
	xml.CreateInstance(MSXML2::CLSID_DOMDocument26);
	
	try {
		xml->loadXML( _bstr_t(plugin->getParmsDef(_variant_t())) );
	}
	catch(_com_error e) {
		_bstr_t text = e.Description();
	}

	return xml;
}
Exemplo n.º 23
0
static HRESULT CreateWADO(MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	HRESULT hr = pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument30));
	if (FAILED(hr)) return hr;
	pXMLDom->preserveWhiteSpace = VARIANT_FALSE;
	pXMLDom->async = VARIANT_FALSE;

	MSXML2::IXMLDOMElementPtr wado;
	MSXML2::IXMLDOMProcessingInstructionPtr pi;
	pi = pXMLDom->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"GBK\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	pi = pXMLDom->createProcessingInstruction("xml-stylesheet", "type=\"text/xml\" href=\"../xslt/wadolist.xsl\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	wado = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "wado_query", "http://www.weasis.org/xsd");
	wado->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
	wado->setAttribute("requireOnlySOPInstanceUID", "false");
	pXMLDom->appendChild(wado);
	wado->setAttribute("wadoURL", "http://localhost/pacs/cgi-bin/");
	/*
	MSXML2::IXMLDOMElementPtr httpTag;
	httpTag = pXMLDom->selectSingleNode("/wado_query/httpTag");
	if( ! httpTag )
	{
		httpTag = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "httpTag", "http://www.weasis.org/xsd");
		wado->appendChild(httpTag);
	}
	httpTag->setAttribute("key", "callingAE");
	httpTag->setAttribute("value", "DEVICE");
	*/
	return S_OK;
}
Exemplo n.º 24
0
int CDLindex::initxml(){
	MSXML2::IXMLDOMDocumentPtr pDoc;

	MSXML2::IXMLDOMElementPtr xmlRoot;

	//创建DOMDocument对象

	HRESULT hr = pDoc.CreateInstance(_uuidof(MSXML2::DOMDocument40));

	if (FAILED(hr))

	{

		MessageBoxA(NULL,"无法创建DOM文件对象,检查是否安装MS XML Parser运行库","error",0);

		return 0;

	}
	return 0;

}
Exemplo n.º 25
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");


    int lCount = m_ouData->m_odVerifySubEntityList.size();
    MSXML2::IXMLDOMElementPtr pIDomSendNode =  pIDOMDoc->createElement(_bstr_t(def_STR_VERIFY_NODE));
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_ATTRIB_FAIL);
    if(pIDomTSAtrrib!= NULL)
    {
        switch(m_ouData->m_eAttributeError)
        {
            case SUCCESS:
                omstrTemp = "SUCCESS";
                break;
            case WARNING:
                omstrTemp = "WARNING";
                break;
            case FATAL:
                omstrTemp = "FATAL";
                break;
            case ERRORS:
            default:
                omstrTemp = "ERRORS";
                break;
        }
        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
        pIDomSendNode->setAttributeNode(pIDomTSAtrrib);
    }

    for(INT i=0; i<lCount; i++)
    {
		CVerifySubEntity *pVerifySubEntity = m_ouData->m_odVerifySubEntityList[i];
        pVerifySubEntity->SetData(pIDomSendNode);
    }
    pIDomTestCaseNode->appendChild(pIDomSendNode);
    return S_OK;
}
Exemplo n.º 26
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CWaitEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CWaitEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    if (pIDOMDoc != NULL)
    {
        MSXML2::IXMLDOMElementPtr pIDomWaitNode =  pIDOMDoc->createElement(_bstr_t(def_STR_WAIT_NODE));

        MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_STTRIB_PURPOSE);
        if(pIDomTSAtrrib!= NULL)
	    {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omPurpose);
		    pIDomWaitNode->setAttributeNode(pIDomTSAtrrib);
	    }
        omstrTemp.Format("%d", m_ouData.m_ushDuration);
        pIDomWaitNode->Puttext(_bstr_t(omstrTemp));

        pIDomTestCaseNode->appendChild(pIDomWaitNode);
    }
    return S_OK;
}
void CreateToolbars()
{
	if (Glb_toolbarArray.GetCount() > 0)
		return;

	IAcadMenuGroup *mnuGrp = NULL;
	if (!getAcadMenuGroup(&mnuGrp))
		return ;

	IAcadToolbars  *tlbrs = NULL;
	HRESULT hr = S_OK;
	hr = mnuGrp->get_Toolbars(&tlbrs);
	mnuGrp->Release();

	// 得到arx所在路径
	TCHAR lpPath[MAX_PATH] = {0};
	GetModuleFileName(GetModuleHandle("DistToolBar.arx"), lpPath, MAX_PATH);
	PathRemoveFileSpec(lpPath);
	PathAddBackslash(lpPath);

	CString strXmlFile = lpPath;
	strXmlFile += "toolbar.xml";

	// 得到icon路径
	PathAppend(lpPath, "icon");
	PathAddBackslash(lpPath);

	MSXML2::IXMLDOMDocumentPtr lpDocument;
	hr = lpDocument.CreateInstance(__uuidof(DOMDocument));

	if ( FAILED(hr) ) 
		_com_raise_error(hr);

	VARIANT_BOOL isSuccessful;

	// 装载XML字符串
	if (!lpDocument->load(_variant_t(strXmlFile)))
	{
		OutputDebugString("LoadXML failed!");

		return;
	}

	MSXML2::IXMLDOMElementPtr lpDocElement = NULL;
	lpDocument->get_documentElement(&lpDocElement);

	// toolbar list
	MSXML2::IXMLDOMNodeListPtr lpToolbarList = lpDocElement->getElementsByTagName(_bstr_t("toolbar"));

	MSXML2::IXMLDOMNodePtr lpToolbar = NULL;

	for ( ; (lpToolbar = lpToolbarList->nextNode()) != NULL ; )
	{

		MSXML2::IXMLDOMNodePtr lpCaptionNode = lpToolbar->attributes->getNamedItem("caption");
		CString strCaption = (char*)lpCaptionNode->text;

		OutputDebugString(strCaption);

		// 添加工具条
		IAcadToolbar  *tlbr = NULL;
		hr = tlbrs->Add(CComBSTR(strCaption), &tlbr);

		if FAILED(hr)
			continue;

		Glb_toolbarArray.Add(strCaption);

		// button list
		MSXML2::IXMLDOMNodeListPtr lpButtonList = lpToolbar->GetchildNodes();

		MSXML2::IXMLDOMNodePtr lpButton = NULL;

		for ( ; (lpButton = lpButtonList->nextNode()) != NULL ; )
		{
			MSXML2::IXMLDOMNodePtr lpToolTipNode = lpButton->attributes->getNamedItem("tooltip");
			CString strToolTip = (char*)lpToolTipNode->text;

			MSXML2::IXMLDOMNodePtr lpCommandNode = lpButton->attributes->getNamedItem("command");
			CString strCommand = (char*)lpCommandNode->text;
			strCommand += " ";

			MSXML2::IXMLDOMNodePtr lpIconNode = lpButton->attributes->getNamedItem("icon");
			CString strIcon = (char*)lpIconNode->text;

			OutputDebugStringX("tooltip=%s, command=%s, icon=%s", strToolTip, strCommand, strIcon);

			// 添加工具按钮
			IAcadToolbarItem *button=NULL;
			VARIANT index;
			index.vt = VT_I4;
			index.lVal = 100l;

			VARIANT vtFalse;
			vtFalse.vt = VT_BOOL;
			vtFalse.boolVal = VARIANT_FALSE;

			CString strIconFile = lpPath;
			strIconFile += strIcon;

			if (!PathFileExists(strIconFile))
			{
				strIconFile = lpPath;
				strIconFile += "dist.ico";
			}

			if (!PathFileExists(strIconFile)) continue;

			hr = tlbr->AddToolbarButton(index, CComBSTR(strToolTip), CComBSTR(strToolTip), CComBSTR(strCommand), vtFalse, &button);

			hr = button->SetBitmaps(CComBSTR(strIconFile), CComBSTR(strIconFile));

			button->Release();
		}

		tlbr->Dock(acToolbarDockRight);//acToolbarFloating
		tlbr->Release();
	}

	tlbrs->Release();

	return;
}
Exemplo n.º 28
0
void XMLDOMParsingNodes(char *szFileName)
{

   try 
   {
	   //Qualify namespase explicitly to avoid Compiler Error C2872 "ambiguous symbol" during linking.
	   //Now Msxml2.dll use the "MSXML2" namespace
	   //(see http://support.microsoft.com/default.aspx?scid=kb;en-us;316317):
	   MSXML2::IXMLDOMDocumentPtr docPtr;//pointer to DOMDocument object
	   MSXML2::IXMLDOMNodeListPtr NodeListPtr;//indexed access. and iteration through the collection of nodes
	   MSXML2::IXMLDOMNodePtr DOMNodePtr;//pointer to the node

	   MSXML2::IXMLDOMNode *pIDOMNode = NULL;//pointer to element's node
	   MSXML2::IXMLDOMNode *pIParentNode = NULL;//pointer to parent node
	   MSXML2::IXMLDOMNode *pIAttrNode = NULL;//pointer to attribute node
	   MSXML2::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr;//iteration through the collection of attribute nodes
	   MSXML2::IXMLDOMNodeList *childList=NULL;//node list containing the child nodes
	  
	 
	  //Variable with the name of node to find: 
	  BSTR strFindText  = L" ";//" " means to output every node

	  //Variables to store item's name, parent, text and node type:
	  BSTR bstrItemText,bstrItemNode, bstrItemParent,bstrNodeType;

	 //Variables to store attribute's name,type and text:	 
	  BSTR bstrAttrName, bstrAttrType, bstrAttrText;

	  HRESULT hResult;
	  
	  int i = 0;//loop-index variable
	  int n = 0;//lines counter
      

	  //Initialize COM Library:
      CoInitialize(NULL);

	 //Create an instance of the DOMDocument object:
      docPtr.CreateInstance(__uuidof(DOMDocument30));
		
      // Load a document:
	  _variant_t varXml(szFileName);//XML file to load
      _variant_t varResult((bool)TRUE);//result 
      
	  varResult = docPtr->load(varXml);

      if ((bool)varResult == FALSE)
	  {
		 //printf("*** Error:failed to load XML file. ***\n");
		 MessageBox(0,"Error: failed to load XML file. Check the file name.", \
			 "Load XML file",MB_OK |MB_ICONWARNING);
         return;
	  }

	  //Collect all or selected nodes by tag name:
	  NodeListPtr = docPtr->getElementsByTagName(strFindText);
  
	  //Output the number of nodes:
	  //printf("Number of nodes: %d\n", (NodeListPtr->length));

	  //Output root node:
	  docPtr->documentElement->get_nodeName(&bstrItemText);
	  //%ls formatting is for wchar_t* parameter's type (%s for char* type):
	  printf("\nRoot: %ls\n", bstrItemText);	
	  

	  for(i = 0; i < (NodeListPtr->length); i++)
	  {
		
			if (pIDOMNode) pIDOMNode->Release();			
			NodeListPtr->get_item(i, &pIDOMNode);
			
			
			if(pIDOMNode )
			{				
					
				pIDOMNode->get_nodeTypeString(&bstrNodeType);
				
				//We process only elements (nodes of "element" type): 
				BSTR temp = L"element";
			
				if (lstrcmp((LPCTSTR)bstrNodeType, (LPCTSTR)temp)==0) 
				{
					n++;//element node's number
					printf("\n\n%d\n", n);//element node's number
					printf("Type: %ls\n", bstrNodeType);

					pIDOMNode->get_nodeName(&bstrItemNode);
					printf("Node: %ls\n", bstrItemNode);				
								 
					pIDOMNode->get_text(&bstrItemText);
					printf("Text: %ls\n", bstrItemText);
					
					pIDOMNode->get_parentNode(&pIParentNode);
					pIParentNode->get_nodeName(&bstrItemParent);
					printf("Parent: %ls\n",bstrItemParent);
					
			
					pIDOMNode->get_childNodes(&childList);
					printf("Child nodes: %d\n", (childList->length));
					
					//Get the attributes:
					int j = 0;//loop-index variable
					long length;// number of attributes in the collection

					DOMNamedNodeMapPtr = pIDOMNode->attributes;
				
					hResult = DOMNamedNodeMapPtr->get_length(&length);
	
					if(SUCCEEDED(hResult))
					{
					//Loop through the number of attributes:
						for(j = 0; j < length; j++)
						{														
							//get attribute node:							
							DOMNamedNodeMapPtr->get_item(j,&pIAttrNode);

							pIAttrNode->get_nodeTypeString(&bstrAttrType);//type as string
							printf("\nAttribute type: %ls\n", bstrAttrType);
							//pIAttrNode->get_nodeType(&bstrAttrType);//enumerated type
							//printf("Attribute type: %d\n", bstrAttrType);
							pIAttrNode->get_nodeName(&bstrAttrName);
							printf("Attribute name: %ls\n", bstrAttrName);
							pIAttrNode->get_text(&bstrAttrText);
							printf("Attribute value: %ls\n", bstrAttrText);						
						
						}
					}					
				//	::MessageBox(NULL, (LPCSTR) bstrItemText,"parsing", MB_OK);		
				}
			}
		}
	//Do not forget to release interfaces:
	pIDOMNode->Release();
	pIDOMNode = NULL;
	pIParentNode->Release();
	pIParentNode = NULL;
		
   } 

   catch(...)
   {
	  MessageBox(NULL, ("*** Exception occurred ***"), ("Error message"), MB_OK);
   }


    CoUninitialize();

}
Exemplo n.º 29
0
/******************************************************************************
Function Name  :  nSaveHeader
Input(s)       :  
Output         :  INT
Functionality  :   
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
Codetag        :  CS025
******************************************************************************/
INT CTestSetupEntity::nSaveHeader(MSXML2::IXMLDOMElementPtr& pIDomHeaderNode, CString& omStrFilePath)
{
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    MSXML2::IXMLDOMElementPtr pChildElement;
    MSXML2::IXMLDOMElementPtr pInfoElement;
    CString omstrTemp;
    //Module Info
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sModuleName.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sModuleName.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
 
    //Version
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sVersion.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sVersion.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
   
    //Engineer Name
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
    bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sEngineerInfo1.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sEngineerInfo1.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
    
    //Engineer Role
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sEngineerInfo2.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sEngineerInfo2.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);

    //Bus Type
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_DBPATH_NODE));
    bAddChildToNode(pInfoElement, def_STR_DATABASE, m_ouTestSetupHeader.m_omDatabasePath);
    pIDomHeaderNode->appendChild(pInfoElement);


    //Database Path
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_BUS_TYPE));
    if(m_ouTestSetupHeader.m_eBus == CAN)
    {
         omstrTemp = "CAN";
    }
    pInfoElement->Puttext(_bstr_t(omstrTemp));
    pIDomHeaderNode->appendChild(pInfoElement);
    
    //Report File
    
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_REPORT_NODE));

    

    if (pInfoElement != NULL)
    {
        switch(m_ouTestSetupHeader.m_sReportFile.m_eType)
        {
            case HTM:
                omstrTemp = "HTM";
                break;
            case TXT:
            default:
                omstrTemp = "TXT";
                break;
        };

        if(m_ouTestSetupHeader.m_sReportFile.m_omPath == "")
        {
            CString omReportPath(omStrFilePath);
            int nIndex = omReportPath.Find(".xml");
            omReportPath.Delete(nIndex, 4);

            CFile omFile(omStrFilePath,  CFile::modeRead);
            CString omReportName = omFile.GetFileTitle() + _T(".") + omstrTemp;
            omReportPath += omReportName;
            m_ouTestSetupHeader.m_sReportFile.m_omPath = omReportPath;
        }
        //Report Path
        bAddChildToNode(pInfoElement, def_STR_PATH_NODE, m_ouTestSetupHeader.m_sReportFile.m_omPath);
        //Extension
        bAddChildToNode(pInfoElement, def_STR_FORMAT_NODE, omstrTemp);

        switch(m_ouTestSetupHeader.m_sReportFile.m_eType)
        {
            case ABS:
                omstrTemp = "ABS";
                break;
            case REL:
            default:
                omstrTemp = "REL";
                break;
        }
        //Time
        bAddChildToNode(pInfoElement, def_STR_TIMEMODE_NODE, omstrTemp);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
    
    return 0;
}
Exemplo n.º 30
0
BOOL WXmlParse::writeParam(const std::vector<WParamDefine *> &params)
{
	/*MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
	return FALSE;
	}

	docRoot = doc->createElement("ModuleName");
	//docRoot->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));

	MSXML2::IXMLDOMElementPtr inputElement = doc->createElement("InputParam");
	docRoot->appendChild(inputElement);
	for (int i = 0;i < params.size();i++)
	{

	}*/

	MSXML2::IXMLDOMDocumentPtr pDoc = NULL; 
	MSXML2::IXMLDOMElementPtr xmlRoot = NULL; 
	MSXML2::IXMLDOMElementPtr xmlInput = NULL; 
	MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL; 
	//创建DOMDocument对象 
	pDoc.CreateInstance(__uuidof(DOMDocument30)); 
	pPI = pDoc->createProcessingInstruction("xml","version='1.0' encoding='gb2312'"); 
	_variant_t vNullVal; 
	vNullVal.vt = VT_NULL; 
	pDoc->insertBefore(pPI, vNullVal);
	//创建元素并添加到文档中 
	xmlRoot = pDoc->createElement((_bstr_t)"ModuleName"); 
	//设置属性 
	
	pDoc->appendChild(xmlRoot);
	appendTextNode(pDoc,xmlRoot,1);

	xmlInput = pDoc->createElement((_bstr_t)"InputParams");
	xmlInput->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));
	xmlRoot->appendChild(xmlInput);
	appendTextNode(pDoc, xmlInput, 2);

	for (int i = 0;i < params.size();i++)
	{
		MSXML2::IXMLDOMElementPtr pProperty = pDoc->createElement((_bstr_t)"Property");
		pProperty->setAttribute((_bstr_t)"name", (_bstr_t)(params[i]->m_name.c_str()));
		xmlInput->appendChild(pProperty);
		appendTextNode(pDoc, pProperty, 3);
		WExtraMap::iterator it = params[i]->m_extraParams.begin();
		while (it != params[i]->m_extraParams.end())
		{
			MSXML2::IXMLDOMElementPtr pText = pDoc->createElement((_bstr_t)it->first.c_str());
			pText->put_text((_bstr_t)it->second.c_str());
			pProperty->appendChild(pText);
			appendTextNode(pDoc, pProperty, 3);
			it++;
		}
	}

	//添加“author”元素 
// 	MSXML2::IXMLDOMElementPtr pNode; 
// 	pNode=pDoc->createElement((_bstr_t)"Bank"); 
// 	xmlRoot->appendChild(pNode);
// 
// 	appendTextNode(pDoc,pNode,2);
// 
// 	MSXML2::IXMLDOMElementPtr pNode2; 
// 	pNode2=pDoc->createElement((_bstr_t)"Head"); 
// 	pNode->appendChild(pNode2);
// 
// 	appendTextNode(pDoc,pNode2,3);
// 
// 	MSXML2::IXMLDOMElementPtr pNode3; 
// 	pNode3=pDoc->createElement((_bstr_t)"PBCCode"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	appendTextNode(pDoc,pNode2,2);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"Code"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	///////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode2,2);
// 	//////////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode,2);
// 
// 	pNode2=pDoc->createElement((_bstr_t)"Table1"); 
// 	pNode->appendChild(pNode2);
// 
// 	appendTextNode(pDoc,pNode2,3);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"PBCCode"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	appendTextNode(pDoc,pNode2,2);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"Code"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	///////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode2,2);
// 	//////////////////////////////////////////////////////
// 
// 	appendTextNode(pDoc,pNode,1);
// 	appendTextNode(pDoc,xmlRoot,0);
// 
 	pDoc->save("D:\\he.xml");

	return TRUE;
}