本文整理汇总了C++中msxml2::IXMLDOMNodeListPtr::get_length方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNodeListPtr::get_length方法的具体用法?C++ IXMLDOMNodeListPtr::get_length怎么用?C++ IXMLDOMNodeListPtr::get_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMNodeListPtr
的用法示例。
在下文中一共展示了IXMLDOMNodeListPtr::get_length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例5: nLoadTestCases
/******************************************************************************
Function Name : nLoadTestCases
Input(s) : MSXML2::IXMLDOMNodePtr& pTSDOM
Output : INT
Functionality :
Member of : CTestSetupEntity
Friend of : -
Author(s) : Venkatanarayana Makam, GT-Derka
Date Created : 06/04/2011
Modifications :
Codetag : CS004
******************************************************************************/
INT CTestSetupEntity::nLoadTestCases(MSXML2::IXMLDOMNodePtr& pTSDOM)
{
LONG lDefaultChannelUsed = 0;
LONG lCount;
_bstr_t bstrNodeName(def_STR_TESTCASE_NODE);
MSXML2::IXMLDOMNodeListPtr pDOMTCNodeList;
MSXML2::IXMLDOMNodePtr pIXMLDOMTestCase;
pDOMTCNodeList = pTSDOM->selectNodes(bstrNodeName);
pDOMTCNodeList->get_length(&lCount);
for(int i=0; i<lCount; i++)
{
CTestCaseEntity odTestCaseEntity;
pIXMLDOMTestCase = pDOMTCNodeList->Getitem(i);
odTestCaseEntity.GetData(pIXMLDOMTestCase);
m_odTestCaseEntityList.AddTail(odTestCaseEntity);
lDefaultChannelUsed += odTestCaseEntity.m_lDefaultChannelUsed;
}
if(lDefaultChannelUsed == 1)
{
AfxMessageBox(_("1 entity without channel-information loaded.\nCAN-Channel 1 selected."), MB_OK | MB_ICONINFORMATION );
}
else if(lDefaultChannelUsed > 1)
{
CString str;
str.Format("%d", lDefaultChannelUsed);
AfxMessageBox(str + _(" entities without channel-information loaded.\nCAN-Channel 1 selected in each case."), MB_OK | MB_ICONINFORMATION );
}
return S_OK;
}
示例6:
int CXMLParser3::GetNodeText_len(LPCTSTR strNodeName,TCHAR *pDestBuffer,int nNode/*=0*/)
{
try
{
HRESULT hr;
MSXML2::IXMLDOMNodeListPtr List = m_pXMLDom->getElementsByTagName((_bstr_t)strNodeName);
long lNodesCount = 0;
hr = List->get_length(&lNodesCount);
if(SUCCEEDED(hr) && (nNode<lNodesCount ))
{
MSXML2::IXMLDOMNodePtr Node = List->item[nNode];
int nLen = _tcslen(Node->text);
if(pDestBuffer==NULL)
{
pDestBuffer = new TCHAR[nLen+1];
}
_tcscpy(pDestBuffer,Node->text);
pDestBuffer[nLen+1]='\0';
return nLen;
}
return 0;
}
catch (_com_error &e)
{
m_nError = e.Error();
m_strError = e.ErrorMessage();
return 0;
}
catch (...)
{
}
return 0;
}
示例7: GetLastElementChild
// 获取当前节点的最后一个Element子节点
IBpXMLNode* CBpXMLNode::GetLastElementChild() const
{
if (m_pDOMNode == NULL)
return NULL;
if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList == NULL)
return NULL;
long nListLen = 0;
pNodeList->get_length(&nListLen);;
MSXML2::IXMLDOMNodePtr pNode = NULL;
for (long i = 0; i < nListLen; i++)
{
pNodeList->get_item(nListLen - 1 - i, &pNode);
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
CBpXMLNode *pNodeCreated = new CBpXMLNode();
pNodeCreated->m_pDOMNode = pNode;
return (IBpXMLNode*)pNodeCreated;
}
}
}
return NULL;
}
示例8: GetCommonVerifyData
/******************************************************************************
Function Name : GetData
Input(s) :
Output : HRESULT
Functionality :
Member of : CVerifyEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
******************************************************************************/
HRESULT CVerifyEntity::GetCommonVerifyData(MSXML2::IXMLDOMNodePtr& pIDomNode, CVerifyData *verifyData)
{
m_ouData = verifyData;
_bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
CComVariant NodeValue;
MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
MSXML2::IXMLDOMNodePtr pIDOMChildNode;
pDOMVerifyAtrributes = pIDomNode->Getattributes();
//bstrNodeName = L"failure";
bstrNodeName.Assign(SysAllocString(CT2W("failure")));
pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
pIDOMChildNode->get_nodeTypedValue(&NodeValue);
CString strTemp;
strTemp = strCopyBSTRToCString(NodeValue);
//m_ouData = new CVerifyData();
if(strTemp == "SUCCESS")
{
m_ouData->m_eAttributeError = SUCCESS;
}
else if(strTemp == "WARNING")
{
m_ouData->m_eAttributeError = WARNING;
}
else if(strTemp == "ERRORS")
{
m_ouData->m_eAttributeError = ERRORS;
}
else
{
m_ouData->m_eAttributeError = FATAL;
}
MSXML2::IXMLDOMNodeListPtr pIDOMSendList;
LONG lCount;
//bstrNodeName = def_STR_VERIFYMSG_NODE;
bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VERIFYMSG_NODE)));
pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
pIDOMSendList->get_length(&lCount);
for(int i = 0; i < lCount; i++)
{
CVerifySubEntity *odVerifySubEntity;
MSXML2::IXMLDOMNodePtr pIXMLDOMVerifyMsgEntity;
pIXMLDOMVerifyMsgEntity = pIDOMSendList->Getitem(i);
//if(CVerifySubEntity::GetData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
if(this->GetSubEntityData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
{
m_ouData->m_odVerifySubEntityList.push_back(odVerifySubEntity);
}
}
return S_OK;
}
示例9: getChildrenCount
size_t getChildrenCount(MSXML2::IXMLDOMNodePtr& node) {
MSXML2::IXMLDOMNodeListPtr children;
const HRESULT getChildNodesRes = node->get_childNodes(&children);
if (FAILED(getChildNodesRes)) {
_com_raise_error(getChildNodesRes);
}
LONG chilrenCount = 0;
const HRESULT getChildenCountRes = children->get_length(&chilrenCount);
if (FAILED(getChildenCountRes)) {
_com_raise_error(getChildenCountRes);
}
return chilrenCount;
}
示例10: CBpXMLNode
// 获取当前节点的指定位置的Element子节点
IBpXMLNode *CBpXMLNode::GetElementChildByIndex(int nIndex) const
{
if (m_pDOMNode == NULL)
return NULL;
if (m_pDOMNode->GetnodeType() != MSXML2::NODE_ELEMENT)
return NULL;
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList == NULL)
return NULL;
long nListLen = 0;
pNodeList->get_length(&nListLen);
if (nIndex <= 0 || nIndex > nListLen)
return NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
int nRealIndex = 0;
int nCount = 0;
for (int i = 0; i < nListLen; i++)
{
pNodeList->get_item(i, &pNode);
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
nCount++;
if (nCount == nIndex)
{
nRealIndex = i;
break;
}
}
}
if (nRealIndex < 0 || nRealIndex >= nListLen)
return NULL;
pNodeList->get_item(nRealIndex, &pNode);
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
CBpXMLNode *pNodeCreated = new CBpXMLNode();
pNodeCreated->m_pDOMNode = pNode;
return (IBpXMLNode*)pNodeCreated;
}
return NULL;
}
示例11: strTempNodeName
// 获取当前结点,指定名称的第index个Element子结点
IBpXMLNode *CBpXMLNode::GetElementChildByName(const wchar_t *szChildNodeName, int nIndex) const
{
if (m_pDOMNode == NULL || nIndex <= 0)
return NULL;
int nCount = nIndex;
if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList == NULL)
return NULL;
long nListLen = 0;
pNodeList->get_length(&nListLen);;
int i = 0;
MSXML2::IXMLDOMNodePtr pNode = NULL;
for (;;)
{
pNodeList->get_item(i, &pNode);
if (pNode == NULL)
break;
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
BSTR bstrText = NULL;
m_pDOMNode->get_nodeName(&bstrText);
CString strTempNodeName(bstrText);
if (strTempNodeName.CompareNoCase(szChildNodeName))
{
nCount--;
if(nCount == 0)
{
CBpXMLNode *pNodeCreated = new CBpXMLNode();
pNodeCreated->m_pDOMNode = pNode;
return (IBpXMLNode*)pNodeCreated;
}
}
}
i++;
if(i == nListLen)
break;
}
}
return NULL;
}
示例12: WalkTree
////////////////////////////////////////////////////////////////////////////
// Function: Walk all the Elements in a loaded XML document.
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(CString& strSearchPattern)
{
HRESULT hr = S_OK;
if (strSearchPattern.IsEmpty())
{
MSXML2::IXMLDOMNodePtr pNode = m_pDoc;
if (pNode == NULL)
return E_FAIL;
hr = WalkTree(0/*iLevel*/, pNode);
}
else
{
//j ("//video");
//j ("//video[@id='crap1']");
//j ("//video[@id='crap1']");
// filter the nodes using the search pattern
MSXML2::IXMLDOMNodeListPtr pNodeList = NULL;
hr = m_pDoc->selectNodes(CComBSTR(strSearchPattern), &pNodeList);
hr = CheckHR(hr, "in the search pattern");
// get the length of the resulting node list
if (pNodeList)
{
long lLength;
hr = pNodeList->get_length(&lLength);
hr = CheckHR(hr, "retrieving node list length");
MSXML2::IXMLDOMNodePtr pNode = NULL;
for (long i = 0; i < lLength; i++)
{
hr = pNodeList->get_item(i, &pNode);
hr = WalkTree(0/*iLevel*/, pNode);
if (hr != S_OK)
return hr;
}
}
}
return hr;
}
示例13: nLoadTestCases
/******************************************************************************
Function Name : nLoadTestCases
Input(s) : MSXML2::IXMLDOMNodePtr& pTSDOM
Output : INT
Functionality :
Member of : CTestSetupEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
Codetag : CS004
******************************************************************************/
INT CTestSetupEntity::nLoadTestCases(MSXML2::IXMLDOMNodePtr& pTSDOM)
{
LONG lCount;
_bstr_t bstrNodeName(def_STR_TESTCASE_NODE);
MSXML2::IXMLDOMNodeListPtr pDOMTCNodeList;
MSXML2::IXMLDOMNodePtr pIXMLDOMTestCase;
pDOMTCNodeList = pTSDOM->selectNodes(bstrNodeName);
pDOMTCNodeList->get_length(&lCount);
for(int i=0; i<lCount;i++)
{
CTestCaseEntity odTestCaseEntity;
pIXMLDOMTestCase = pDOMTCNodeList->Getitem(i);
odTestCaseEntity.GetData(pIXMLDOMTestCase);
m_odTestCaseEntityList.AddTail(odTestCaseEntity);
}
return S_OK;
}
示例14: GetElementCount
// 获取当前节点的所有Element子节点个数
int CBpXMLNode::GetElementCount() const
{
if (m_pDOMNode == NULL)
return 0;
long nResult = 0;
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList != NULL)
{
MSXML2::IXMLDOMNodePtr pNode = NULL;
long nListLen = 0;
pNodeList->get_length(&nListLen);
for (long i = 0; i < nListLen; i++)
{
pNodeList->get_item(i, &pNode);
if (pNode != NULL && pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
nResult++;
}
}
return (int)nResult;
}
示例15: GetData
/******************************************************************************
Function Name : GetData
Input(s) : MSXML2::IXMLDOMNodePtr& pIDomNode
Output : HRESULT
Functionality : Reads the XML node and constructs the data structure
Member of : CSendEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
******************************************************************************/
HRESULT CSendEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
MSXML2::IXMLDOMNodeListPtr pIDOMSendList;
_bstr_t bstrNodeName = def_STR_SENDMSG_NODE;
long lCount;
pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
pIDOMSendList->get_length(&lCount);
for(int i = 0; i < lCount; i++)
{
CSend_MessageEntity odSend_MessageEntity;
MSXML2::IXMLDOMNodePtr pIXMLDOMSendMsgEntity;
pIXMLDOMSendMsgEntity = pIDOMSendList->Getitem(i);
if(odSend_MessageEntity.GetData(pIXMLDOMSendMsgEntity)==S_OK)
{
m_ouData.m_odSend_MessageDataList.AddTail(odSend_MessageEntity);
}
}
return S_OK;
}