本文整理汇总了C++中IXMLDOMNode::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::Release方法的具体用法?C++ IXMLDOMNode::Release怎么用?C++ IXMLDOMNode::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCommentNode
/*
Function name : CXML::CreateCommentNode
Description : This helper function creates a comment for the node supplied as argumnet
Return type : bool
Argument : IXMLDOMNode **pParentNode
Argument : CString csComment
*/
bool CXML::CreateCommentNode(IXMLDOMNode **ppParentNode,CString &rcsComment)
{
if(rcsComment.IsEmpty())
return false;
if(!(*ppParentNode))
return false;
IXMLDOMNode * pNode = NULL;
_variant_t vtNodeType((long)VT_I4,NODE_COMMENT);
_bstr_t bstrNameSpace("");
m_hr = m_pXMLDoc->createNode(vtNodeType,bstrNameSpace,bstrNameSpace,&pNode);
if(!SUCCEEDED(m_hr))
return false;
_variant_t vtComment(rcsComment);
m_hr = pNode->put_nodeValue(vtComment);
if(!SUCCEEDED(m_hr))
{
pNode->Release();
return false;
}
IXMLDOMNode * pINewNode = NULL;
bool bRet = AddNode(&m_pICurrentNode,&pNode,&pINewNode,NODE_COMMENT);
if(pNode)
pNode->Release();
if(pINewNode)
pINewNode->Release();
return bRet;
}
示例2: GetDataWithXPath
bool CNtlXMLDoc::GetDataWithXPath(WCHAR* pwszXPath, WCHAR* pwszResultData, int nBufferSizeInWChars)
{
if (NULL == pwszXPath || NULL == pwszResultData || 0 >= nBufferSizeInWChars)
return false;
IXMLDOMNode* pNode = NULL;
m_pXMLDocument->selectSingleNode(pwszXPath, &pNode);
if(!pNode)
return false;
BSTR bstr = NULL;
if (FAILED(pNode->get_text(&bstr)))
{
::SysFreeString(bstr);
pNode->Release();
return false;
}
wcscpy_s(pwszResultData, nBufferSizeInWChars, bstr);
::SysFreeString(bstr);
pNode->Release();
return true;
}
示例3: PreviousSibling
/*
Function name : CXML::PreviousSibling
Description : This will move the current node to the previous sibling of the current node.
Return type : bool
Tested : Ok
*/
bool CXML::PreviousSibling()
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pITempNode = m_pICurrentNode;
IXMLDOMNode * pNode = NULL;
pITempNode->AddRef();
m_hr = pITempNode ->get_previousSibling(&pNode);
pITempNode->Release();
if (!SUCCEEDED(m_hr) || !pNode)
return false;
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode= NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}
示例4: DeleteNode
/*
Function name : CXML::DeleteNode
Description : This function will delete the current node
Return type : bool
Tested : Ok
*/
bool CXML::DeleteNode()
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pNode = NULL;
m_hr = m_pICurrentNode->get_nextSibling(&pNode);
if (!SUCCEEDED(m_hr))
return false;
if(!pNode)
{
m_hr = m_pICurrentNode->get_parentNode(&pNode);
if (!SUCCEEDED(m_hr))
return false;
}
if(!pNode)
return false;
Delete(&m_pICurrentNode);
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode = NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}
示例5: RemoveAttributeNode
/*
Function name : CXML::CreateTextNode
Description : This helper function create an attribute to the node supplied as argumnet
Return type : bool
Argument : IXMLDOMNode **pParentNode
Argument : CString csAttribute
Argument : CString csValue
*/
bool CXML::RemoveAttributeNode(IXMLDOMNode **pParentNode,CString csAttribute)
{
IXMLDOMNode * pNode = NULL;
if(csAttribute.IsEmpty())
return false;
if(!(*pParentNode))
return false;
IXMLDOMNamedNodeMap * pAttributes = NULL;
m_hr = (*pParentNode)->get_attributes(&pAttributes);
if(!SUCCEEDED(m_hr) || !pAttributes)
return false;
IXMLDOMNode *pRemovedNode = NULL;
_bstr_t bstrAttribute(csAttribute);
m_hr = pAttributes->removeNamedItem(bstrAttribute,&pRemovedNode);
pAttributes->Release();
if(!SUCCEEDED(m_hr) || !pRemovedNode)
return false;
pRemovedNode->Release();
return true;
}
示例6: AddElement
CXmlElement* CXmlElement::AddElement(LPWSTR pwszName)
{
HRESULT hr = S_OK;
CXmlElement *pElement = NULL;
IXMLDOMElement *pIElement = NULL;
BSTR bstrName = ::SysAllocString(pwszName);
if (NULL != m_pIDoc)
{
hr = m_pIDoc->createElement(bstrName, &pIElement);
if (SUCCEEDED(hr))
{
IXMLDOMNode *pNewNode = NULL;
hr = m_pIElement->appendChild(pIElement, &pNewNode);
if (SUCCEEDED(hr))
{
pElement = new CXmlElement(m_pIDoc, pIElement);
pNewNode->Release();
pNewNode = NULL;
}
pIElement->Release();
pIElement = NULL;
}
}
::SysFreeString(bstrName);
return pElement;
}
示例7: GetAttribute
std::wstring CXmlNode::GetAttribute(LPCTSTR lpAttributeName)
{
IXMLDOMNamedNodeMap* lpNamedNodeMap;
IXMLDOMNode* lpXMLNode;
BSTR bstrValue;
std::wstring strValue;
HRESULT hr;
if (NULL == lpAttributeName || NULL == m_pXMLNode)
return _T("");
lpNamedNodeMap = NULL;
hr = m_pXMLNode->get_attributes(&lpNamedNodeMap);
if (hr == S_OK)
{
lpXMLNode = NULL;
hr = lpNamedNodeMap->getNamedItem((WCHAR *)lpAttributeName, &lpXMLNode);
if (hr == S_OK)
{
hr = lpXMLNode->get_text(&bstrValue);
if (hr == S_OK)
{
strValue = (WCHAR *)bstrValue;
::SysFreeString(bstrValue);
}
lpXMLNode->Release();
}
lpNamedNodeMap->Release();
}
return strValue;
}
示例8: doXPATH
// return "" if no value at path
std::string lvDCOMInterface::doXPATH(const std::string& xpath)
{
if (m_pxmldom == NULL)
{
throw std::runtime_error("m_pxmldom is NULL");
}
epicsGuard<epicsMutex> _lock(m_lock);
std::map<std::string,std::string>::const_iterator it = m_xpath_map.find(xpath);
if (it != m_xpath_map.end())
{
return it->second;
}
IXMLDOMNode *pNode = NULL;
std::string S_res;
BSTR bstrValue = NULL;
HRESULT hr = m_pxmldom->selectSingleNode(_bstr_t(xpath.c_str()), &pNode);
if (SUCCEEDED(hr) && pNode != NULL)
{
hr=pNode->get_text(&bstrValue);
if (SUCCEEDED(hr))
{
S_res = envExpand(CW2CT(bstrValue));
SysFreeString(bstrValue);
}
pNode->Release();
}
// else
// {
// throw std::runtime_error("doXPATH: cannot find " + xpath);
// }
m_xpath_map[xpath] = S_res;
return S_res;
}
示例9: GetNodeAttributeValue
bool CXML::GetNodeAttributeValue(IXMLDOMNode ** ppNode,CString csAttributeName,CString &rcsValue)
{
IXMLDOMNode *pNodeAttribute = NULL;
IXMLDOMNamedNodeMap *pNodeMap = NULL;
CString csTemp;
if(!ppNode || !(*ppNode))
return false;
m_hr = (*ppNode)->get_attributes(&pNodeMap);
if (SUCCEEDED(m_hr) == 0 || pNodeMap == NULL)
return false;
_bstr_t bstrAttributeName(csAttributeName);
m_hr = pNodeMap->getNamedItem (bstrAttributeName,&pNodeAttribute);
pNodeMap->Release();
if (SUCCEEDED(m_hr) == 0 || (pNodeAttribute == NULL))
return false;
_variant_t vtAttributeVal;
m_hr = pNodeAttribute->get_nodeValue(&vtAttributeVal);
pNodeAttribute->Release();
if (SUCCEEDED(m_hr) == 0)
return false;
rcsValue = vtAttributeVal.bstrVal;
return true;
}
示例10: MoveToParentNode
/*
Function name : CXML::MoveToParentNode
Description : This function will move to the n th parent the current node.
Return type : bool
Argument : UINT nNthParent
Tested : Ok
*/
bool CXML::MoveToParentNode(UINT nNthParent)
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pITempNode = m_pICurrentNode;
IXMLDOMNode * pNode = NULL;
pITempNode->AddRef();
for(UINT i=0;i<nNthParent;++i)
{
if(pNode)
{
pNode ->Release();
pNode = NULL;
}
m_hr = pITempNode ->get_parentNode(&pNode);
if (!SUCCEEDED(m_hr) || !pNode)
{
pITempNode->Release();
return false;
}
if(pITempNode)
{
pITempNode->Release();
pITempNode = NULL;
}
pITempNode = pNode;
pITempNode->AddRef();
}
if(pNode)
{
pITempNode->Release();
m_pICurrentNode->Release();
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
pNode= NULL;
}
return true;
}
示例11: CreateAttributeNode
/*
Function name : CXML::CreateAttributeNode
Description :
Return type : bool
Argument : IXMLDOMNode **pParentNode
Argument : CString csAttribute
Argument : CString csValue
Tested : Ok
*/
bool CXML::CreateAttributeNode(IXMLDOMNode **pParentNode,CString csAttribute,CString csValue)
{
IXMLDOMNode * pNode = NULL;
if(csAttribute.IsEmpty())
return false;
if(!(*pParentNode))
return false;
_variant_t vtNodeType((long)NODE_ATTRIBUTE);
_bstr_t bstrName(csAttribute);
_bstr_t bstrNameSpace("");
m_hr = m_pXMLDoc->createNode(vtNodeType,bstrName,bstrNameSpace,&pNode);
if(!SUCCEEDED(m_hr))
return false;
IXMLDOMNamedNodeMap * pAttributes = NULL;
m_hr = (*pParentNode)->get_attributes(&pAttributes);
if(!SUCCEEDED(m_hr) || !pAttributes)
{
pNode->Release();
return false;
}
IXMLDOMNode *pNewNode = NULL;
m_hr = pAttributes->setNamedItem(pNode,&pNewNode);
pNode->Release();
pAttributes->Release();
if(!SUCCEEDED(m_hr) || !pNewNode)
return false;
_variant_t vtValue(csValue);
m_hr = pNewNode->put_nodeValue(vtValue);
pNewNode->Release();
if(!SUCCEEDED(m_hr) || !pNewNode)
return false;
return true;
}
示例12: SetAttributeValue
bool CXML::SetAttributeValue(CString csPathToNode,CString csAttributeName,CString csValue,bool bCurrentNodeAsBase)
{
IXMLDOMNode * pNode = NULL;
if(!GetNode(&pNode,csPathToNode,NULL,NULL,bCurrentNodeAsBase))
return false;
if(RemoveAttributeNode(&pNode,csAttributeName))
if(CreateAttributeNode(&pNode,csAttributeName,csValue))
{
pNode->Release();
m_pIRootNode->Release();
return true;
}
pNode->Release();
return false;
}
示例13:
IXMLDOMNode *CXML::NextChildNode(IXMLDOMNode **ppNode)
{
if(!(*ppNode))
return NULL;
IXMLDOMNode * pNode = NULL;
IXMLDOMNodeList * pChildList = NULL;
// Get the list of child nodes of the current node
m_hr = (*ppNode)->get_childNodes(&pChildList);
if (!SUCCEEDED(m_hr))
return NULL;
// loop through the childs
DOMNodeType nodeType;
while(true)
{
// Get the node type of each child, if it is of NODE_ELEMENT type set it as current node
m_hr = pChildList->nextNode(&pNode);
if(!SUCCEEDED(m_hr))
{
pChildList->Release();
return NULL;
}
if(!pNode) break;
m_hr = pNode->get_nodeType(&nodeType);
if(!SUCCEEDED(m_hr))
{
pChildList->Release();
pNode->Release();
return NULL;
}
if(nodeType == NODE_ELEMENT)
break;
if(pNode)
pNode->Release();
}
if(pChildList)
pChildList->Release();
return pNode;
}
示例14: ConfGetListNodeByName
/**
* получение xml-узла из списка по его имени
* @param NodeName имя искомого узла
* @param pIDOMNodeList дескриптор списка
* @return дескриптор нужного узла, или NULL в случае неудачи
* @see ConfGetNodeByName()
* @see ConfGetNodeText()
* @see ConfGetTextByName()
*/
IXMLDOMNode * ConfGetListNodeByName(BSTR NodeName, IXMLDOMNodeList *pIDOMNodeList)
{
IXMLDOMNode *Ret = NULL;
LONG len = 0;
if (pIDOMNodeList == NULL)
{
return NULL;
}
HRESULT hr = pIDOMNodeList->get_length(&len);
if (SUCCEEDED(hr))
{
pIDOMNodeList->reset();
for (int i = 0; i < len; i++)
{
IXMLDOMNode *pIDOMChildNode = NULL;
hr = pIDOMNodeList->get_item(i, &pIDOMChildNode);
if (SUCCEEDED(hr))
{
BSTR ChildNodeName = NULL;
hr = pIDOMChildNode->get_nodeName(&ChildNodeName);
if (SUCCEEDED(hr))
{
if (!wcscmp(NodeName, ChildNodeName))
{
Ret = pIDOMChildNode;
}
}
if (ChildNodeName)
{
SysFreeString(ChildNodeName);
}
if (Ret)
{
return Ret;
}
pIDOMChildNode->Release();
pIDOMChildNode = NULL;
}
else
{
DbgMsg(__FILE__, __LINE__, "pIDOMNodeList->get_item() ERROR 0x%.8x\n", hr);
}
}
}
else
{
DbgMsg(__FILE__, __LINE__, "pIDOMNodeList->get_length() ERROR 0x%.8x\n", hr);
}
return NULL;
}
示例15: GoToNodeEx
/*
Function name : CXML::GoToNode
Description : Moves to the node having the specified text
Return type : bool
Argument : CString csPathToNode
Argument : CString csNodeText
Argument : bool bCurrentNodeAsBase
Tested : Not working
*/
bool CXML::GoToNodeEx(CString csPathToNode,CString csNodeText,bool bCurrentNodeAsBase)
{
CString csPath;
IXMLDOMNode *pBaseNode = NULL;
if(bCurrentNodeAsBase)
{
if(!m_pICurrentNode) return false;
pBaseNode = m_pICurrentNode;
pBaseNode->AddRef();
csPath.Format("./%s[.= \"%s\"]",csPathToNode,csNodeText);
}
else
{
if(!m_pIRootNode) return false;
pBaseNode = m_pIRootNode;
pBaseNode->AddRef();
csPath.Format("/%s[.= \"%s\"]",csPathToNode,csNodeText);
}
BSTR bstrPath = csPath.AllocSysString();
IXMLDOMNode * pNode = NULL;
m_hr = pBaseNode->selectSingleNode(bstrPath,&pNode);
pBaseNode->Release();
SysFreeString(bstrPath);
if(!SUCCEEDED(m_hr) || !pNode)
return false;
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode = NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}