本文整理汇总了C++中msxml2::IXMLDOMDocumentPtr::GetdocumentElement方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocumentPtr::GetdocumentElement方法的具体用法?C++ IXMLDOMDocumentPtr::GetdocumentElement怎么用?C++ IXMLDOMDocumentPtr::GetdocumentElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMDocumentPtr
的用法示例。
在下文中一共展示了IXMLDOMDocumentPtr::GetdocumentElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: readParam
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;
}
示例6: initSourcesTab
// InitSourcesTab
BOOL CDataSourcesManager::initSourcesTab(LPCTSTR config_file_path)
{
CString FName; // jmeno (cesta) ke konfig. souboru
FName = config_file_path;
BSTR FileName = FName.AllocSysString();
// nacteni konfiguracniho souboru zdroju
MSXML2::IXMLDOMDocumentPtr pXMLDom; // koren XML stromu
MSXML2::IXMLDOMElementPtr pNode; // korenovy element
MSXML2::IXMLDOMNodeListPtr pChildren; // seznam podelementu korenoveho elementu
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) "SOURCES_LIST") // spravny nazev korenoveho elementu
{
pChildren = pNode->childNodes; // ziskani seznamu potomku
pChild = NULL;
while((pChild = pChildren->nextNode()) != NULL) // zpracovavaji se potomci
{
if(pChild->baseName == (_bstr_t) "SOURCE") // definice polozky v tabulce zdroju
{
// pridani prvku do tabulky zdroju
SourcesTab.Add(new CSourceRec);
// PUBLIC_ID
Atr_val = pChild->getAttribute("PUBLIC_ID");
if(Atr_val.vt != VT_NULL)
SourcesTab[i]->PublicID = (BSTR) (_bstr_t) Atr_val;
// PERZISTENT_ID
Atr_val = pChild->getAttribute("PERZISTENT_ID");
if(Atr_val.vt != VT_NULL)
SourcesTab[i]->PerzistID = (BSTR) (_bstr_t) Atr_val;
// PLUGIN_ID
Atr_val = pChild->getAttribute("PLUGIN_ID");
if(Atr_val.vt != VT_NULL)
SourcesTab[i]->PluginID = (BSTR) (_bstr_t) Atr_val;
i++;
}
}
}
//dedek: nacteni default source
MSXML2::IXMLDOMElementPtr el_default_source = pNode->selectSingleNode("DEFAULT_SOURCE");
if (el_default_source)
setDefaultSource((public_source_id_t) (LPCTSTR) (_bstr_t) el_default_source->getAttribute("PUBLIC_ID"));
}
}
SysFreeString(FileName);
pXMLDom.Release();
// nastaveni odkazu na tabulku zasuvek prvkum z tabulky zdroju
for(int j=0; j<= SourcesTab.GetUpperBound(); j++) // pres polozky v tabulce zdroju
{
for(int k=0; k<=PlugsTab.GetUpperBound(); k++)
{
if(SourcesTab[j]->PluginID == PlugsTab[k].PluginName)
{
SourcesTab[j]->PluginIndex = k; // nastaveni indexu v tabulce zasuvek
break;
}
}
}
return TRUE;
}
示例7: LoadGroups
BOOL CIconImgList::LoadGroups( MSXML2::IXMLDOMDocumentPtr& piDocument)
{
// グループの追加処理
MSXML2::IXMLDOMElementPtr piRoot;
piRoot = piDocument->GetdocumentElement();
if( NULL == piRoot)
{
return FALSE;
}
MSXML2::IXMLDOMElementPtr piGroups;
piGroups = piRoot->selectSingleNode( _bstr_t( _T( "GROUPS")));
if( NULL == piGroups)
{
return FALSE;
}
m_nGroupCount = GetGroupCount( piGroups);
if( 0 < m_nGroupCount)
{
int nParent = 0;
m_astGroupData = new GROUPDATA*[ m_nGroupCount];
ZeroMemory( m_astGroupData, sizeof( GROUPDATA*) * m_nGroupCount);
PickUpGroups( piGroups, nParent);
/*
_bstr_t cBstrName;
BOOL blEnable;
MSXML2::IXMLDOMElementPtr piGroup;
_bstr_t cBstr;
_variant_t cVariant;
TCHAR szWork[ 32];
for( int nIndex = 0; nIndex < m_nGroupCount; nIndex++)
{
wsprintf( szWork, _T( "//GROUP[@ID='%d']"), nIndex + 1);
piGroup = piRoot->selectSingleNode( _bstr_t( szWork));
if( NULL == piGroup)
{
continue;
}
cBstrName = piGroup->getAttribute( _bstr_t( _T( "TITLE")));
cVariant = piGroup->getAttribute( _bstr_t( _T( "ENABLE")));
VariantChangeType( &cVariant, &cVariant, 0, VT_BOOL);
blEnable = ( VARIANT_FALSE == cVariant.boolVal) ? FALSE : TRUE;
if( 0 >= cBstrName.length())cBstrName = _T( "new group!");
m_astGroupData[ nIndex] = ( GROUPDATA*)malloc( sizeof( GROUPDATA) + ( sizeof( TCHAR) * ( cBstrName.length() + 1)));
if( NULL != m_astGroupData[ nIndex])
{
m_astGroupData[ nIndex]->nParent = nParent;
if( 1 <= nParent)
{
if( FALSE == m_astGroupData[ nParent - 1]->blEnable)
{
blEnable = FALSE;
}
}
m_astGroupData[ nIndex]->blEnable = blEnable;
lstrcpy( m_astGroupData[ nIndex]->szName, cBstrName);
}
}*/
}
return TRUE;
}
示例8: LoadIcons
BOOL CIconImgList::LoadIcons( MSXML2::IXMLDOMDocumentPtr& piDocument)
{
BOOL blResult = FALSE;
MSXML2::IXMLDOMElementPtr piRoot;
piRoot = piDocument->GetdocumentElement();
if( NULL == piRoot)
{
return FALSE;
}
MSXML2::IXMLDOMElementPtr piGroups;
piGroups = piRoot->selectSingleNode( _bstr_t( _T( "GROUPS")));
MSXML2::IXMLDOMElementPtr piIcons;
piIcons = piRoot->selectSingleNode( _bstr_t( _T( "ICONS")));
if( NULL == piIcons)
{
return FALSE;
}
MSXML2::IXMLDOMNodeListPtr piIconsList;
piIconsList = piIcons->GetchildNodes();
if( NULL == piIconsList)
{
return FALSE;
}
long lIconsCount;
lIconsCount = piIconsList->Getlength();
if( 0 >= lIconsCount)
{
return FALSE;
}
m_nCountExtend = lIconsCount;
if( 0 < m_nCountExtend)
{
m_astIconStatus = new ICONSTATUS[ m_nCountExtend];
if( NULL != m_astIconStatus)
{
/*
ZeroMemory( m_astIconStatus, sizeof( ICONSTATUS) * m_nCountExtend);
*/
for( int nIndex = 0; nIndex < m_nCountExtend; nIndex++)
{
m_astIconStatus[ m_nEnableCount].nID = 0;
m_astIconStatus[ m_nEnableCount].blEnable = FALSE;
m_astIconStatus[ m_nEnableCount].nParent = 0;
m_astIconStatus[ m_nEnableCount].nPosition = 0;
m_astIconStatus[ m_nEnableCount].cStrIconName.Empty();
}
int nHeight = ( m_nCountExtend / 10) + ( ( m_nCountExtend % 10) ? 1 : 0);
m_hBmpExtend = ::CreateBitmap( _ICON_WIDTH * 10, _ICON_HEIGHT * nHeight, 1, 1, NULL);
HDC hExtDC = ::CreateCompatibleDC( NULL);
HDC hDefDC = ::CreateCompatibleDC( NULL);
HDC hWorkDC = ::CreateCompatibleDC( NULL);
HBITMAP hOldExtBmp = ( HBITMAP)::SelectObject( hExtDC, m_hBmpExtend);
HBITMAP hOldDefBmp = ( HBITMAP)::SelectObject( hDefDC, m_hBmpDefault);
m_nEnableCount = 0;
CString cStrEntry;
LPBYTE lpabyData;
TCHAR szWork[ 64];
MSXML2::IXMLDOMElementPtr piIcon;
MSXML2::IXMLDOMElementPtr piImage;
MSXML2::IXMLDOMElementPtr piParent;
_variant_t cVariant;
_bstr_t cBstr;
CString strTitle;
for( int nIndex = 0; nIndex < m_nCountExtend; nIndex++)
{
cVariant = VARIANT_TRUE;
if( NULL != piGroups)
{
wsprintf( szWork, _T( "//ITEM[@REF='%d']"), nIndex + 1);
piIcon = piGroups->selectSingleNode( _bstr_t( szWork));
if( NULL != piIcon)
{
cVariant = piIcon->getAttribute( _bstr_t( _T( "ENABLE")));
if( cVariant.vt != VT_NULL)
{
VariantChangeType( &cVariant, &cVariant, 0, VT_BOOL);
}
else
{
cVariant = VARIANT_TRUE;
}
}
}
if( VARIANT_FALSE != cVariant.boolVal)
{
wsprintf( szWork, _T( "//ICON[@ID='%d']"), nIndex + 1);
piIcon = piRoot->selectSingleNode( _bstr_t( szWork));
if( NULL == piIcon)
{
//.........这里部分代码省略.........