本文整理汇总了C++中IXMLDOMNode::get_parentNode方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::get_parentNode方法的具体用法?C++ IXMLDOMNode::get_parentNode怎么用?C++ IXMLDOMNode::get_parentNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::get_parentNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNodePath
/*
Function name : CXML::GetNodePath
Description : This function will return the full path of the xml file. (Max up to
: 100 Nodes)
Return type : bool
Argument : CString &rcsPath
Tested : Ok
*/
bool CXML::GetNodePath(CString &rcsPath)
{
if(!m_pICurrentNode)
return false;
char * path[100] = {0};
IXMLDOMNode * pCurNode = m_pICurrentNode;
IXMLDOMNode * pParentNode = NULL;
pCurNode->AddRef();
CString csNodeText;
int i = 0;
try
{
do
{
m_hr = pCurNode->get_parentNode(&pParentNode);
if(!SUCCEEDED(m_hr))
{
pCurNode->Release();
throw 1;
}
else if(!pParentNode)
break;
BSTR bstrNodeText;
m_hr = pParentNode->get_nodeName(&bstrNodeText);
pCurNode->Release();
pCurNode = pParentNode;
pCurNode->AddRef();
pParentNode->Release();
if(!SUCCEEDED(m_hr))
{
throw 1;
}
long nLen = wcslen(bstrNodeText)+1;
path[i] = new char[nLen];
WideCharToMultiByte(CP_ACP,0,bstrNodeText,-1,path[i],nLen,NULL,NULL);
SysFreeString(bstrNodeText);
i++;
}
while(true);
delete [] path[--i];
for(--i;i>=0;--i)
{
rcsPath += path[i];
rcsPath +="/";
delete [] path[i];
}
GetCurrentNodeName(csNodeText);
rcsPath +=csNodeText;
return true;
}
catch(...)
{
rcsPath = "";
for(--i;i>=0;--i)
delete [] path[i];
return false;
}
}