本文整理汇总了C++中msxml2::IXMLDOMDocumentPtr::get_documentElement方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocumentPtr::get_documentElement方法的具体用法?C++ IXMLDOMDocumentPtr::get_documentElement怎么用?C++ IXMLDOMDocumentPtr::get_documentElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMDocumentPtr
的用法示例。
在下文中一共展示了IXMLDOMDocumentPtr::get_documentElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateToolbars
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;
//.........这里部分代码省略.........
示例2: ParseSOAPRequest
int CSOAPUtil::ParseSOAPRequest(char* xml, int xmlSize, SOAP_REQUEST_INFO* info)
{
int res = NO_ERR;
MSXML2::IXMLDOMDocumentPtr xmlDoc;
HRESULT hr = xmlDoc.CreateInstance(MSXML2::CLSID_DOMDocument);
if(FAILED(hr)) {
return ERR_FALSE;
}
xmlDoc->put_async(VARIANT_FALSE);
xmlDoc->put_preserveWhiteSpace(VARIANT_TRUE);
if( LoadDOMDocument(xml, xmlSize, xmlDoc) != NO_ERR ) {
xmlDoc.Release();
xmlDoc = NULL;
return ERR_FALSE;
}
//���
MSXML2::IXMLDOMElementPtr pElemRoot;
MSXML2::IXMLDOMNodePtr mediaNode = NULL;
xmlDoc->get_documentElement(&pElemRoot);
if( pElemRoot == NULL ) {
res = ERR_FALSE;
goto Err_End;
}
for( int i=0; i<pElemRoot->childNodes->length; i++ ) {
MSXML2::IXMLDOMNodePtr bodyNode = pElemRoot->childNodes->Getitem(i);
CComBSTR localName;
bodyNode->get_baseName(&localName);
if( localName == NULL ) {
continue;
}
if(CompareNoCase(L"Body", localName.m_str) == 0 ) {
for( int j=0; j<bodyNode->childNodes->length; j++ ) {
MSXML2::IXMLDOMNodePtr actionNode = bodyNode->childNodes->Getitem(j);
CComBSTR actionName;
actionNode->get_baseName(&actionName);
if( actionName == NULL ) {
continue;
}
info->actionName = actionName;
for( int k=0; k<actionNode->childNodes->length; k++) {
MSXML2::IXMLDOMNodePtr argNode = actionNode->childNodes->Getitem(k);
CComBSTR argName;
argNode->get_baseName(&argName);
if( argName == NULL ) {
continue;
}
CComBSTR argVal;
argNode->get_text(&argVal);
info->argList.insert(pair<wstring,wstring>(argName.m_str, argVal.m_str));
}
}
break;
}
}
Err_End:
xmlDoc.Release();
xmlDoc = NULL;
return res;
}