本文整理汇总了C++中msxml2::IXMLDOMNodePtr::GetnodeType方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNodePtr::GetnodeType方法的具体用法?C++ IXMLDOMNodePtr::GetnodeType怎么用?C++ IXMLDOMNodePtr::GetnodeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMNodePtr
的用法示例。
在下文中一共展示了IXMLDOMNodePtr::GetnodeType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: HasElementChildNodes
// 判断当前节点是否存在Element子结点
bool CBpXMLNode::HasElementChildNodes() const
{
if(m_pDOMNode == NULL)
return false;
if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT)
{
MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
if (pNodeList == NULL)
return false;
long nListLen = 0;
pNodeList->get_length(&nListLen);
MSXML2::IXMLDOMNodePtr pNode = NULL;
for (int i = 0; i < nListLen; i++)
{
pNodeList->get_item(i, &pNode);
if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
return true;
}
}
return false;
}