本文整理汇总了C++中msxml2::IXMLDOMDocument2Ptr::CreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocument2Ptr::CreateInstance方法的具体用法?C++ IXMLDOMDocument2Ptr::CreateInstance怎么用?C++ IXMLDOMDocument2Ptr::CreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMDocument2Ptr
的用法示例。
在下文中一共展示了IXMLDOMDocument2Ptr::CreateInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: str
MSXML2::IXMLDOMDocument2Ptr CXmlBase::GetXmlDocPtrByStream(CComBSTR bstrXml
, CString strXmlPathFile)
{
CString str(_T(""));
HRESULT hr = S_OK;
MSXML2::IXMLDOMDocument2Ptr pDoc;
//载入到xml文档结构中
hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if (FAILED(hr))
{
//WRITELOG("END, FAILED TO INVOKE pDoc.CreateInstance");
return NULL;
}
pDoc->async = VARIANT_FALSE; //加载方式为“同步”
pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。
if (VARIANT_FALSE == pDoc->loadXML(bstrXml.m_str))
{
//WRITELOG("END, FAILED TO INVOKE pDoc->loadXML");
return NULL;
}
if (!strXmlPathFile.IsEmpty())
{
if (S_OK != pDoc->save((LPCTSTR)strXmlPathFile))
{
//WRITELOG("END, FAILED TO INVOKE pDoc->save");
}
}
return pDoc;
}
示例2: LoadShootSolutionSector
void CShootManagerSys::LoadShootSolutionSector(int iSector, LPCTSTR szFilename)
{
if(iSector >= m_ShootSolutionSectorArray.Num()) return;
int i;
MSXML2::IXMLDOMDocument2Ptr pDoc;
pDoc.CreateInstance(__uuidof(DOMDocument40));
pDoc->load((_variant_t)szFilename);
// 성공한 슛부터 로드한다.
MSXML2::IXMLDOMNodeListPtr pNodeListSuccess = pDoc->selectNodes(L"root/success");
for(i=0; i<pNodeListSuccess->Getlength(); i++)
{
MSXML2::IXMLDOMNodePtr pNodeSuccess = pNodeListSuccess->Getitem(i);
CShootSolution Solution;
Solution.Create(pNodeSuccess, true, this);
m_ShootSolutionSectorArray[iSector].first.push_back(Solution);
}
MSXML2::IXMLDOMNodeListPtr pNodeListFail = pDoc->selectNodes(L"root/fail");
for(i=0; i<pNodeListFail->Getlength(); i++)
{
MSXML2::IXMLDOMNodePtr pNodeFail = pNodeListFail->Getitem(i);
CShootSolution Solution;
Solution.Create(pNodeFail, false, this);
m_ShootSolutionSectorArray[iSector].second.push_back(Solution);
}
pDoc.Release();
}
示例3: Exception
MSXML2::IXMLDOMDocument2Ptr ValidateConfigXML()
{
wchar_t moduleFileName[MAX_PATH] = {0};
if(0 == GetModuleFileNameW(GetModuleHandle(_T("TestConnectSdk.dll")/*"TestConnectAPITool.dll"*/), moduleFileName, MAX_PATH))
throw Workshare::Exception(_T("Failed to obtain the filename of the current module"));
CStdStringW schemaUrl;
schemaUrl.Format(L"res://%s/ConnectAPITestTool.xsd", moduleFileName);
MSXML2::IXMLDOMDocument2Ptr spConfigSchema;
HRESULT hr = spConfigSchema.CreateInstance(__uuidof(MSXML2::DOMDocument60));
if(FAILED(hr))
throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
if(VARIANT_TRUE != spConfigSchema->load(schemaUrl.c_str()))
ThrowMSXMLParseError(spConfigSchema->parseError, _T("Failed to load 'ConnectAPITestTool.xsd'."));
MSXML2::IXMLDOMSchemaCollection2Ptr spSchemaCollection;
hr = spSchemaCollection.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60));
if(FAILED(hr))
throw Workshare::ClassNotFoundException(_T("Msxml2.XMLSchemaCache.6.0"), _T("Failed to create an XML schema collection."));
hr = spSchemaCollection->add(L"", spConfigSchema.GetInterfacePtr());
if(S_OK != hr)
throw Workshare::Exception(_T("Failed to add 'ConnectAPITestTool.xsd' to schema collection."));
MSXML2::IXMLDOMDocument2Ptr spConfigXML;
hr = spConfigXML.CreateInstance(__uuidof(MSXML2::DOMDocument60));
if(FAILED(hr))
throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
spConfigXML->async = VARIANT_FALSE;
spConfigXML->resolveExternals = VARIANT_FALSE;
spConfigXML->validateOnParse = VARIANT_FALSE;
spConfigXML->schemas = spSchemaCollection.GetInterfacePtr();
if(VARIANT_TRUE != spConfigXML->load(L"ConnectAPITestTool.xml"))
ThrowMSXMLParseError(spConfigXML->parseError, _T("Failed to load 'ConnectAPITestTool.xml'."));
MSXML2::IXMLDOMParseErrorPtr spError = spConfigXML->validate();
if(S_OK != spError->errorCode)
ThrowMSXMLParseError(spError, _T("Failed to validate 'ConnectAPITestTool.xml'."));
return spConfigXML;
}
示例4:
MSXML2::IXMLDOMDocument2Ptr CXmlBase::CreateXmlDocPtr(void)
{
::CoInitialize(NULL);
MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if (FAILED(hr))
{
return NULL;
}
pDoc->async = VARIANT_FALSE; //加载方式为“同步”
pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。
//pDoc->preserveWhiteSpace = VARIANT_TRUE;
return pDoc;
}
示例5: WordEditorInsertActiveElement
void CWordManager::WordEditorInsertActiveElement(void)
{
CElementManager & em = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->ElementManager;
LPCTSTR strElementName = getLastElementName();
//load element
int element_index = em.ElementIdFromName(strElementName);
MSXML2::IXMLDOMElementPtr active_element =
em.CreateEmptyElement(element_index);
//load document
MSXML2::IXMLDOMDocument2Ptr doc;
doc.CreateInstance(_T("Msxml2.DOMDocument"));
em.LoadSkeletonDTD((MSXML2::IXMLDOMDocumentPtr &) doc);
//insert element to chapter and document
doc->documentElement->
appendChild(em.CreateEmptyElement(ELID_CHAPTER))->
appendChild(active_element);
//configure by dialog
if (CSkeletonDoc::EditActiveElement(active_element))
{
//transform and generate
CAElTransform transform(active_element);
transform.DoAllTransnformations();
#ifdef _DEBUG
MSXML2::IXMLDOMParseErrorPtr err = doc->validate();
if (err->errorCode != S_OK)
{
AfxMessageBox(err->reason);
AfxMessageBox(active_element->selectSingleNode("output")->xml);
}
#endif
GenerateXMLStringToWordEditor(active_element->xml);
}
active_element.Release();
doc.Release();
}
示例6: setupXMLParser
MSXML2::IXMLDOMDocument2Ptr setupXMLParser(char *path)
{
HRESULT hr;
MSXML2::IXMLDOMDocument2Ptr xmlDoc;
hr = CoInitialize(NULL);
hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr)) return NULL;
if (xmlDoc->load(path) != VARIANT_TRUE) return NULL;
hr = xmlDoc->setProperty("SelectionNamespaces", "xmlns:r='http://www.collada.org/2005/11/COLLADASchema'");
hr = xmlDoc->setProperty("SelectionLanguage", "XPath");
return xmlDoc;
}
示例7: FAILED
CRDPConfig::CRDPConfig(const char *configFile)
{
// Local variables and initializations
HRESULT hResult = S_OK;
char cNodeType;
// set the defaults
mConfigError = false; // TODO - check for config error - report in Capture Fail
mDrive = "C:";
mRoot = "/DATA"; // NOTE: don't use backslash in file names
mInfoDrive = "C:";
mInfoRoot = "/xampp/htdocs/RDP_Data";
mInfoFile = "messages.log";
mMsgLogDrive = "C:";
mMsgLogRoot = "/xampp/htdocs/RDP_Data";
mMsgLogFile = "messages.log";
mTestDataDrive = "C:";
mTestDataRoot = "/DATA/TestData";
//mTestDataEnabled = false;
mDebugLevel = -1;
mMSSListenerPort = 65000;
mDrive = "C:";
mRoot = "\\DATA\\";
mLeadInSize = 21;
mDataBlockSize = 150;
mLeadOutSize = 0;
mNoOfCards = 2;
mNoOfPortsPerCard = 4;
// Read the XML file and update the config values
// Initialize the COM library
hResult = CoInitialize(NULL);
if (FAILED(hResult))
{
MsgLog::Error("RDPConfig module - Failed to initialize COM environment");
return;
}
// Main try block for MSXML DOM operations
try
{
// MSXML COM smart pointers
// Use the Dccument2 class to enable schema validation
MSXML2::IXMLDOMDocument2Ptr spDocInput;
MSXML2::IXMLDOMNodePtr spNodeTemp;
MSXML2::IXMLDOMElementPtr spElemTemp;
MSXML2::IXMLDOMAttributePtr spAttrTemp;
MSXML2::IXMLDOMNodeListPtr spNLChildren;
// Create the COM DOM Document object
hResult = spDocInput.CreateInstance(__uuidof(DOMDocument));
if FAILED(hResult)
{
MsgLog::Error("RDPConfig module - Failed to create Document instance");
return;
}
// Load the document synchronously
spDocInput->async = VARIANT_FALSE;
// Load input document. MSXML default for load is to
// validate while parsing.
hResult = spDocInput->load(configFile);
// Check for load, parse, or validation errors
if( hResult != VARIANT_TRUE)
{
MsgLog::Error("Parsing error reading config file %s", configFile);
return;
} else {
MsgLog::Info("Config file %s opened successfully", configFile);
}
// Get document element
spElemTemp = spDocInput->documentElement;
if (Debug::Enabled(Debug::CONFIG))
std::cout<<std::endl<<"Document Element name: "<<spElemTemp->nodeName<<std::endl;
// Walk through children of document element
// and process according to type
spNodeTemp = spElemTemp->firstChild;
// TODO more checking needed for the config file
while (spNodeTemp != NULL)
{
// Process node depending on type
cNodeType = spNodeTemp->nodeType;
switch (cNodeType)
{
// Comment Node
case NODE_COMMENT:
if (Debug::Enabled(Debug::CONFIG))
std::cout<<"Comment Node:" << std::endl << " "<<_bstr_t(spNodeTemp->nodeValue)<<std::endl;
break;
// Element Node
case NODE_ELEMENT:
{
//.........这里部分代码省略.........
示例8: LoadShootSolutionSet
void CShootManagerSys::LoadShootSolutionSet(LPCTSTR szFilename)
{
int i;
MSXML2::IXMLDOMDocument2Ptr pDoc;
pDoc.CreateInstance(__uuidof(DOMDocument40));
pDoc->load((_variant_t)szFilename);
// 시뮬레이터에서 사용하는 거리 범위들을 로드한다.
MSXML2::IXMLDOMNodeListPtr pNodeListDistance;
MSXML2::IXMLDOMNodePtr pNodeDistance;
float fDistance;
pNodeListDistance = pDoc->selectNodes(L"root/distance_range/distance");
for(i=0; i<pNodeListDistance->Getlength(); i++)
{
pNodeDistance = pNodeListDistance->Getitem(i);
_bstr_t distance = pNodeDistance->GetnodeTypedValue();
sscanf((LPCTSTR)distance, "%f", &fDistance);
m_DistanceList.push_back(fDistance);
}
// 시뮬레이터에서 사용하는 각도 범위들을 로드한다.
// 여기서 각도는 (골대 - 슈터) 와 양의 z 축 사이의 각도를 말한다.
// degree 로 저장되어 있으므로 Angle 로 변환시킨다.
MSXML2::IXMLDOMNodeListPtr pNodeListAngle;
MSXML2::IXMLDOMNodePtr pNodeAngle;
float fDegree;
int iAngle;
pNodeListAngle = pDoc->selectNodes(L"root/angle_range/degree");
for(i=0; i<pNodeListAngle->Getlength(); i++)
{
pNodeAngle = pNodeListAngle->Getitem(i);
_bstr_t degree = pNodeAngle->GetnodeTypedValue();
sscanf((LPCTSTR)degree, "%f", &fDegree);
iAngle = Degree2Angle(fDegree); // degree 에서 Angle 로 변환한다.
m_AngleList.push_back(iAngle);
}
// 전체 섹터 개수를 계산하고 여기에 맞게 메모리를 생성한다.
int iNumSector = m_DistanceList.size() * (m_AngleList.size() + 1) + 6;
for(i=0; i<iNumSector; i++)
{
ShootSolutionSector *pShootSolutionSector = new (m_ShootSolutionSectorArray) ShootSolutionSector;
}
// 각 섹터별로 섹터안의 Shoot Solution 들을 로드한다.
MSXML2::IXMLDOMNodeListPtr pNodeListSector = pDoc->selectNodes(L"root/sector");
MSXML2::IXMLDOMNodePtr pNodeSector;
MSXML2::IXMLDOMNodePtr pNodeIndex;
MSXML2::IXMLDOMNodePtr pNodePath;
for(i=0; i<pNodeListSector->Getlength(); i++)
{
pNodeSector = pNodeListSector->Getitem(i);
pNodeIndex = pNodeSector->selectSingleNode(L"index");
pNodePath = pNodeSector->selectSingleNode(L"path");
_bstr_t index = pNodeIndex->GetnodeTypedValue();
_bstr_t path = pNodePath->GetnodeTypedValue();
int iIndex = atoi((LPCTSTR)index);
SString sFilePath = szFilename;
sFilePath = DGetPathOnly(sFilePath);
sFilePath += "\\";
sFilePath += (LPCTSTR)path;
// sFilePath.Format("%s\\%s\\%s", g_szCurrentPath, g_szSimulatorPath, (LPCTSTR)path);
LoadShootSolutionSector(iIndex, (LPCTSTR)sFilePath);
}
pDoc.Release();
}
示例9: LoadContent
bool Engine::LoadContent()
{
// Setup our SpriteBatch.
m_pSpriteBatch = new DirectX::SpriteBatch(d3dContext_);
m_pFont->Initialize(d3dDevice_, std::wstring(L"Calibri18.spritefont"));
m_pSprite->Initialize(d3dDevice_, std::wstring(L"Test.dds"), 10.0f, 10.0f);
m_textToDisplay = Text();
m_textToDisplay.Initialize(std::wstring(L"Sarah"), DirectX::SimpleMath::Vector2(200.0f, 200.0f));
try
{
MSXML2::IXMLDOMDocument2Ptr xmlDoc;
HRESULT hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);
teamStats.InitializeTeam("Players.xml");
// Make sure the file was loaded correctly before trying to load the players.
if (xmlDoc->load("Players.xml") == VARIANT_TRUE)
{
//xmlDoc->setProperty("SelectionLanguage", "XPath");
//teamStats.LoadPlayers(xmlDoc);
}
if (xmlDoc->load("input.xml") != VARIANT_TRUE)
{
DXTRACE_MSG("Unable to load input.xml\n");
xmlDoc->save("input.xml");
//xmlDoc->
}
else
{
DXTRACE_MSG("XML was successfully loaded \n");
xmlDoc->setProperty("SelectionLanguage", "XPath");
MSXML2::IXMLDOMNodeListPtr wheels = xmlDoc->selectNodes("/Car/Wheels/*");
DXTRACE_MSG("Car has %u wheels\n", wheels->Getlength());
DXTRACE_MSG(wheels->Getitem(0)->text);
//ptr->
MSXML2::IXMLDOMNodePtr node;
node = xmlDoc->createNode(MSXML2::NODE_ELEMENT, ("Engine"), (""));
node->text = ("Engine 1.0");
xmlDoc->documentElement->appendChild(node);
hr = xmlDoc->save("output.xml");
if (SUCCEEDED(hr))
{
DXTRACE_MSG("output.xml successfully saved\n");
}
}
}
catch (_com_error &e)
{
DXTRACE_MSG(e.ErrorMessage());
}
return true;
}