本文整理汇总了C++中msxml2::IXMLDOMDocument2Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocument2Ptr类的具体用法?C++ IXMLDOMDocument2Ptr怎么用?C++ IXMLDOMDocument2Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IXMLDOMDocument2Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: InsertEnterAndTabs
MSXML2::IXMLDOMNodePtr CXmlBase::InsertEnterAndTabs(MSXML2::IXMLDOMNodePtr pParentNode, MSXML2::IXMLDOMNodePtr pNode, int nLevel)
{
HRESULT hr = S_OK;
MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
MSXML2::IXMLDOMTextPtr pTabsText = NULL;
MSXML2::IXMLDOMNodePtr pTabsNode = NULL;
MSXML2::IXMLDOMElementPtr pElement = NULL;
CString strText(_T("")), strTabs(_T(""));
CComBSTR bstrText;
if (nLevel < 0
|| pParentNode == NULL) return NULL;
if(pNode == NULL)nLevel = 0;
for (int i=0; i<nLevel; i++)
{
strTabs += _T("\t");
}
strText.Format(_T("%s%s"), _T("\r\n"), (LPCTSTR)strTabs);
bstrText = _bstr_t(strText).GetBSTR();
try
{
pDoc = pParentNode->GetownerDocument();
if (pDoc == NULL) return NULL;
pTabsText = pDoc->createTextNode((LPCTSTR)strText);
if (pTabsText == NULL) return NULL;
CComVariant varNode = pNode.GetInterfacePtr();
pTabsNode = pParentNode->insertBefore(pTabsText, varNode);
//hr = pDoc->raw_createTextNode(bstrText.m_str, &pTabsText);
//if (FAILED(hr) || pTabsText == NULL) return NULL;
//pElement = pTabsText;
//pTabsNode = pParentNode->appendChild(pElement);
//pTabsNode = pDoc->createTextNode((LPCTSTR)strText);
//if (pTabsNode == NULL) return NULL;
//pNode = pNode->appendChild(pTabsNode);
}
catch(_com_error &e)
{
CString str;
str.Format(_T("创建xml节点发生异常。\r\nComError:\r\n%s")
, e.ErrorMessage());
::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
return NULL;
}
catch(...)
{
return NULL;
}
return pTabsNode;
}
示例3: SetNameSpace
BOOL CXmlBase::SetNameSpace(MSXML2::IXMLDOMDocument2Ptr& pDoc, LPCTSTR lpszNameSpace)
{
HRESULT hr = S_OK;
if (lpszNameSpace == NULL
|| pDoc == NULL) return FALSE;
hr = pDoc->setProperty("SelectionLanguage", "XPath");
if (FAILED(hr)) return FALSE;
hr = pDoc->setProperty("SelectionNamespaces", lpszNameSpace);
if (FAILED(hr)) return FALSE;
return TRUE;
}
示例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: GetNodePtr
//取得指定xpath的节点
MSXML2::IXMLDOMNodePtr CXmlBase::GetNodePtr(LPCTSTR lpszXPath
, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
if (pDoc == NULL || lpszXPath == NULL) return NULL;
CComBSTR bstrText = _bstr_t(lpszXPath).GetBSTR();
return pDoc->selectSingleNode(bstrText.m_str);
}
示例8: SetNodeValue
//设置指定xpath的节点值
BOOL CXmlBase::SetNodeValue(LPCTSTR lpszValue, LPCTSTR lpszXPath
, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
if (pDoc == NULL || lpszXPath == NULL) return FALSE;
MSXML2::IXMLDOMNodeListPtr pNodeList = pDoc->selectNodes(lpszXPath);
long lCnt = pNodeList->Getlength();
if (lCnt == 0) return FALSE;
MSXML2::IXMLDOMNodePtr pNode = pNodeList->Getitem(0);
return SetNodeValue(lpszValue, pNode);
}
示例9: readGeometry
void readGeometry(dae_reader_t *reader, MSXML2::IXMLDOMDocument2Ptr xmlDoc)
{
MSXML2::IXMLDOMNodeListPtr nodeList;
nodeList = xmlDoc->selectNodes("/r:COLLADA/r:library_geometries/r:geometry");
int count = nodeList->length;
for (int i = 0; i < count; i++)
{
MSXML2::IXMLDOMNodePtr node = nodeList->Getitem(i);
readMesh(reader, node);
}
}
示例10: 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();
}
示例11: CreateRootNode
MSXML2::IXMLDOMNodePtr CXmlBase::CreateRootNode(MSXML2::IXMLDOMDocument2Ptr pDoc
, LPCTSTR lpszRootText)
{
HRESULT hr = S_OK;
MSXML2::IXMLDOMElementPtr pElement = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
CComBSTR bstrRootText = _bstr_t("root").GetBSTR();
if (pDoc == NULL) return NULL;
if (lpszRootText != NULL)
bstrRootText = lpszRootText;
if (bstrRootText.Length() == 0) return NULL;
try
{
//hr = pDoc->raw_createElement(bstrRootText.m_str, &pElement);
//if (FAILED(hr) || pElement == NULL) return NULL;
//pNode = pElement;
pNode = pDoc->createNode(NODE_ELEMENT, bstrRootText.m_str, _T(""));
if (pNode == NULL) return NULL;
//hr = pDoc->raw_appendChild(pNode, NULL);
//if (FAILED(hr)) return NULL;
pNode = pDoc->appendChild(pNode);
}
catch(_com_error &e)
{
CString str;
str.Format(_T("创建xml根节点发生异常。\r\nComError:\r\n%s")
, e.ErrorMessage());
::MessageBox( NULL, str, g_sAppTitle, MB_OK|MB_ICONERROR);
return NULL;
}
catch(...)
{
return NULL;
}
return pNode;
}
示例12: InsertNode
MSXML2::IXMLDOMNodePtr CXmlBase::InsertNode( MSXML2::IXMLDOMNodePtr pParentNode , MSXML2::IXMLDOMNodePtr pNodeBack , LPCTSTR lpszNodeText )
{
HRESULT hr = S_OK;
MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
MSXML2::IXMLDOMElementPtr pElement = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
CComBSTR bstrNodeText = _bstr_t("node").GetBSTR();
if (pParentNode == NULL
|| lpszNodeText == NULL) return NULL;
bstrNodeText = lpszNodeText;
if (bstrNodeText.Length() == 0) return NULL;
try
{
pDoc = pParentNode->GetownerDocument();
if (pDoc == NULL) return NULL;
//hr = pDoc->raw_createElement(bstrNodeText.m_str, &pElement);
//if (FAILED(hr) || pElement == NULL) return NULL;
pNode = pDoc->createNode(NODE_ELEMENT, bstrNodeText.m_str, _T(""));
if (pNode == NULL) return NULL;
CComVariant varNode = pNodeBack.GetInterfacePtr();
pNode = pParentNode->insertBefore(pNode, varNode);
}
catch(_com_error &e)
{
CString str;
str.Format(_T("插入xml节点发生异常。\r\nComError:\r\n%s")
, e.ErrorMessage());
::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
return NULL;
}
catch(...)
{
return NULL;
}
return pNode;
}
示例13: CreateXmlTitle
MSXML2::IXMLDOMNodePtr CXmlBase::CreateXmlTitle(MSXML2::IXMLDOMDocument2Ptr pDoc)
{
MSXML2::IXMLDOMProcessingInstructionPtr pi = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
if (pDoc == NULL) return NULL;
try
{
pi = pDoc->createProcessingInstruction(_T("xml")
, _T("version=\"1.0\" encoding=\"UTF-8\""));
if (pi == NULL) return NULL;
pNode = pi;
if (NULL == (pNode = pDoc->appendChild(pNode)))
{
pi.Release();
pNode.Release();
return NULL;
}
pi.Release();
//pNode.Release();
}
catch(_com_error &e)
{
CString str;
str.Format(_T("创建xml头发生异常。\r\nComError:\r\n%s")
, e.ErrorMessage());
::MessageBox( NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
return NULL;
}
catch(...)
{
return NULL;
}
return pNode;
}
示例14: GetNodeListPtr
MSXML2::IXMLDOMNodeListPtr CXmlBase::GetNodeListPtr(LPCTSTR lpszXPath
, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
MSXML2::IXMLDOMNodeListPtr pNodeList;
CComBSTR bstrText;
if (lpszXPath == NULL)
{
return NULL;
}
if (pDoc == NULL)
{
return NULL;
}
bstrText = _bstr_t(lpszXPath).GetBSTR();
pNodeList = pDoc->selectNodes(bstrText.m_str);
return pNodeList;
}
示例15: getAxisOrientation
void getAxisOrientation(dae_reader_t *reader, MSXML2::IXMLDOMDocument2Ptr xmlDoc)
{
MSXML2::IXMLDOMNodePtr node = xmlDoc->selectSingleNode("/r:COLLADA/r:asset/r:up_axis");
reader->x = 0;
reader->y = 1;
reader->z = 2;
if (node != NULL)
{
string orientation = node->text;
if (orientation[0] == 'Y')
{
reader->z = 1;
reader->y = 2;
}
}
}