Пример #1
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;
}
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;
}
Пример #3
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;
}
Пример #4
0
static HRESULT CreatePatientNode(DcmDirectoryRecord *patientRecord, MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	MSXML2::IXMLDOMElementPtr patient, wado;
	wado = pXMLDom->selectSingleNode("/wado_query");
	if(wado == NULL) return CO_E_NOT_SUPPORTED;
	patient = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Patient", "http://www.weasis.org/xsd");
	if(patient == NULL) return CO_E_NOT_SUPPORTED;

	const char *patientName = NULL, *patientID = NULL, *patientBirthDate = NULL, *patientBirthTime = NULL, *patientSex = NULL;
	if(patientRecord->findAndGetString(DCM_PatientsName, patientName).bad()) return CO_E_NOT_SUPPORTED;
	else patient->setAttribute("PatientName", patientName);
	if(patientRecord->findAndGetString(DCM_PatientID, patientID).bad()) return CO_E_NOT_SUPPORTED;
	else patient->setAttribute("PatientID", patientID);
	if(patientRecord->findAndGetString(DCM_PatientsBirthDate, patientBirthDate).good())
		patient->setAttribute("PatientBirthDate", patientBirthDate);
	if(patientRecord->findAndGetString(DCM_PatientsBirthTime, patientBirthTime).good())
		patient->setAttribute("PatientBirthTime", patientBirthTime);
	if(patientRecord->findAndGetString(DCM_PatientsSex, patientSex).good())
		patient->setAttribute("PatientSex", patientSex);

	wado->appendChild(patient);

	DcmDirectoryRecord *studyRec = NULL;
	while(studyRec = patientRecord->nextSub(studyRec))
	{
		if(studyRec->getRecordType() != ERT_Study) continue;
		CreateStudyNode(studyRec, patient, pXMLDom);
	}
	return S_OK;
}
Пример #5
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;
}
Пример #6
0
bool XmlIOStreamImp::WriteNodeAttribute(const CString& attrName, const CString& attrValue)
{
	DATA_ASSERT(!mbIsRead);
	if(mbIsRead)
		return false; // Can't write to the read stream.

	DATA_ASSERT(mpCurrentNode != NULL);
	if(NULL == mpCurrentNode)
		return false;

	MSXML2::IXMLDOMDocumentPtr xmlDocument = mpCurrentNode->GetownerDocument();
	if (xmlDocument)
	{
		// Create attribute node
		MSXML2::IXMLDOMAttributePtr attr = xmlDocument->createAttribute((LPCTSTR)attrName);

		VARIANT va;
		va.vt=VT_BSTR;
		va.bstrVal = attrValue.AllocSysString();
		attr->put_value(va);

		mpCurrentNode->attributes->setNamedItem(attr);

		VariantClear(&va);

		return true;
	}

	return false;
}
Пример #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;
}
Пример #8
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();
	}
Пример #9
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;
}
Пример #10
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;
}
// 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;
}
Пример #12
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertBefore(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)refNode);
			return newNode.Detach();
		}
		return NULL;
	}
Пример #13
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;
}
Пример #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;
}
Пример #15
0
CyNode CyDoc::LoadXML(const std::wstring& lpContent)
{
	MSXML2::IXMLDOMDocumentPtr spDoc;
	try
	{
		spDoc = GetDocument();
		if(spDoc!=NULL){
			spDoc->loadXML(lpContent.c_str());
		}
	} catch(...) {
	}
	m_spDocument = spDoc;
	return CyNode(spDoc);
}
Пример #16
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;
}
Пример #17
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;
}
Пример #18
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			MSXML2::IXMLDOMNode* refNode = GetNode(index);
			if (refNode)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		return NULL;
	}
Пример #19
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling();
			if (nextNode.GetInterfacePtr() != NULL)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)nextNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		return NULL;
	}
Пример #20
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;
}
Пример #21
0
static HRESULT CreateStudyNode(DcmDirectoryRecord *studyRec, MSXML2::IXMLDOMElementPtr &patient, MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	MSXML2::IXMLDOMElementPtr study = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Study", "http://www.weasis.org/xsd");
	if(study == NULL) return CO_E_NOT_SUPPORTED;

	const char *buff = NULL, *studyUID = NULL;
	if(studyRec->findAndGetString(DCM_StudyInstanceUID, studyUID).bad()) return CO_E_NOT_SUPPORTED;
	else study->setAttribute("StudyInstanceUID", studyUID);
	if(studyRec->findAndGetString(DCM_StudyDate, buff).bad()) return CO_E_NOT_SUPPORTED;
	else study->setAttribute("StudyDate", buff);
	if(studyRec->findAndGetString(DCM_StudyTime, buff).good()) study->setAttribute("StudyTime", buff);
	if(studyRec->findAndGetString(DCM_StudyID, buff).good()) study->setAttribute("StudyID", buff);
	if(studyRec->findAndGetString(DCM_AccessionNumber, buff).good()) study->setAttribute("AccessionNumber", buff);
	if(studyRec->findAndGetString(DCM_StudyDescription, buff).good()) study->setAttribute("StudyDescription", buff);
	if(studyRec->findAndGetString(DCM_ReferringPhysiciansName, buff).good()) study->setAttribute("ReferringPhysicianName", buff);
	patient->appendChild(study);

	DcmDirectoryRecord *seriesRec = NULL;
	while(seriesRec = studyRec->nextSub(seriesRec))
	{
		if(seriesRec->getRecordType() != ERT_Series) continue;
		CreateSeriesNode(seriesRec, study, pXMLDom, studyUID);
	}
	return S_OK;
}
Пример #22
0
// 往xml文件里添加换行、制表符
void WXmlParse::appendTextNode(MSXML2::IXMLDOMDocumentPtr &pDoc, MSXML2::IXMLDOMElementPtr &element, UINT childLevel)
{
	CString text(_T("\r\n"));
	for (UINT i = 0;i < childLevel;i++)
		text += "\t";
	element->appendChild(pDoc->createTextNode((_bstr_t)text));   
}
Пример #23
0
/******************************************************************************
Function Name  :  FormatDOMDocument
Input(s)       :  MSXML2::IXMLDOMDocumentPtr pDoc
                  CString& omstrFilePath
Output         :  bool
Functionality  :  Formats the pDoc Pointer into File omStrFilePath
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
BOOL CTestSetupEntity::FormatDOMDocument(MSXML2::IXMLDOMDocumentPtr pDoc, CString& omstrFilePath)
{
    //Referance Taken From Msdn
    MSXML2::ISAXXMLReaderPtr pSaxXmlReader = NULL;
    pSaxXmlReader.CreateInstance(L"Msxml2.SAXXMLReader");
    CComPtr<IStream> pStream;
    DWORD grfMode = STGM_WRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE;

    //W4 Removal
    if(SHCreateStreamOnFile ((LPCTSTR)omstrFilePath, grfMode, &pStream) == S_OK)
    {
        MSXML2::IMXWriterPtr pImxWriter;
        pImxWriter.CreateInstance (L"Msxml2.MXXMLWriter");
        pImxWriter->put_output (CComVariant(pStream));
        pSaxXmlReader->putContentHandler((MSXML2::ISAXContentHandlerPtr)pImxWriter);
        pSaxXmlReader->putErrorHandler((MSXML2::ISAXErrorHandlerPtr)pImxWriter);
        pSaxXmlReader->putDTDHandler((MSXML2::ISAXDTDHandlerPtr)pImxWriter);
        pImxWriter->put_byteOrderMark(VARIANT_TRUE);
        pImxWriter->put_indent(VARIANT_TRUE);
        //W4 Removal
        pSaxXmlReader->parse((_variant_t)(pDoc.GetInterfacePtr()));
        pImxWriter->flush ();
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
Пример #24
0
	void CXmlNodeWrapper::SetValue(LPCTSTR valueName,LPCTSTR value)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNamedNodeMapPtr attributes = m_xmlnode->Getattributes();
			if (attributes)
			{
				MSXML2::IXMLDOMAttributePtr attribute = xmlDocument->createAttribute(valueName);
				if (attribute)
				{
					attribute->Puttext(value);
					attributes->setNamedItem(attribute);
				}
			}
		}
	}
Пример #25
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;
}
Пример #26
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);
		}
	}
}
Пример #27
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;
}
Пример #28
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;
}
Пример #29
0
MSXML2::IXMLDOMNodePtr createNode(MSXML2::IXMLDOMDocumentPtr& xmlDoc, 
      const String& nodeName) {
  MSXML2::IXMLDOMNodePtr res = xmlDoc->createNode(1, nodeName.c_str(), _T("")); 
  if (res == NULL) {
    throw XMLUtils::ParseError();
  }

  return res;
}
Пример #30
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;
}