本文整理汇总了C++中msxml2::IXMLDOMDocumentPtr::CreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocumentPtr::CreateInstance方法的具体用法?C++ IXMLDOMDocumentPtr::CreateInstance怎么用?C++ IXMLDOMDocumentPtr::CreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMDocumentPtr
的用法示例。
在下文中一共展示了IXMLDOMDocumentPtr::CreateInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBuffer
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;
}
示例2: readObject
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;
}
示例3: nParseTSFile
/******************************************************************************
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;
}
示例4: readExtendModName
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;
}
示例5: NotifyHandler
/*
* 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;
}
示例6: SetData
/******************************************************************************
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;
}
示例7: GetDocument
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: SaveFileAs
/******************************************************************************
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;
}
示例9: Clone
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();
}
示例10: SetData
/******************************************************************************
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;
}
示例11: readCalculateParams
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;
}
示例12: loadStylesFromXML
// 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;
}
示例13: LoadExtIconData
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;
}
示例14: SetData
/******************************************************************************
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: saveStylesToXML
// 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;
}