本文整理汇总了C++中IXMLDOMNode::removeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::removeChild方法的具体用法?C++ IXMLDOMNode::removeChild怎么用?C++ IXMLDOMNode::removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::removeChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Delete
/*
Function name : CXML::Delete
Description : This helper function delete the node supplied node
Return type : bool
Argument : IXMLDOMNode **ppRemoveNode
Tested : Ok
*/
bool CXML::Delete(IXMLDOMNode **ppRemoveNode)
{
if(!(*ppRemoveNode)) return false;
IXMLDOMNode * pParentNode = NULL;
IXMLDOMNode * pRemovedNode = NULL;
m_hr = (*ppRemoveNode)->get_parentNode(&pParentNode );
if(!SUCCEEDED(m_hr) || !pParentNode)
return false;
m_hr = pParentNode->removeChild(*ppRemoveNode,&pRemovedNode);
pParentNode->Release();
if(!SUCCEEDED(m_hr) || !pRemovedNode)
return false;
pRemovedNode->Release();
return true;
}
示例2: New
// New
bool COpcXmlDocument::New(IXMLDOMElement* ipElement)
{
HRESULT hResult = S_OK;
IXMLDOMElement* ipClone = NULL;
IXMLDOMNode* ipParent = NULL;
IXMLDOMNode* ipResult = NULL;
TRY
{
// create new document instance.
if (!New())
{
THROW_(hResult, E_FAIL);
}
// clone the element.
hResult = ipElement->cloneNode(VARIANT_TRUE, (IXMLDOMNode**)&ipClone);
if (FAILED(hResult))
{
THROW();
}
// remove clone from parent.
hResult = ipClone->get_parentNode(&ipParent);
if (FAILED(hResult))
{
THROW();
}
if (ipParent != NULL)
{
hResult = ipParent->removeChild(ipClone, &ipResult);
if (FAILED(hResult))
{
THROW();
}
if (ipResult != NULL)
{
ipResult->Release();
ipResult = NULL;
}
}
// add root element to document.
hResult = m_ipDocument->appendChild(ipClone, &ipResult);
if (FAILED(hResult))
{
THROW();
}
if (ipResult != NULL)
{
ipResult->Release();
ipResult = NULL;
}
// declare element as the document element.
hResult = m_ipDocument->putref_documentElement(ipClone);
if (FAILED(hResult))
{
THROW();
}
// add predefined namespaces
AddNamespace(TAG_XSD, OPCXML_NS_SCHEMA);
AddNamespace(TAG_XSI, OPCXML_NS_SCHEMA_INSTANCE);
}
CATCH
{
Clear();
}
FINALLY
{
// release memory.
if (ipClone != NULL) ipClone->Release();
if (ipParent != NULL) ipParent->Release();
if (ipResult != NULL) ipResult->Release();
}
return SUCCEEDED(hResult);
}
示例3: WcaFinalize
//.........这里部分代码省略.........
ExitOnFailure(hr, "failed to process CustomActionData");
hr = WcaReadStringFromCaData(&pwz, &pwzValue);
ExitOnFailure(hr, "failed to process CustomActionData");
// Set the additional attribute
hr = XmlSetAttribute(pixnNewNode, pwzName, pwzValue);
ExitOnFailure2(hr, "failed to set attribute: %ls to value %ls", pwzName, pwzValue);
cAdditionalChanges--;
}
ReleaseNullObject(pixnNewNode);
break;
case xaDeleteValue:
if (pwzName && *pwzName)
{
// Delete the attribute
hr = XmlRemoveAttribute(pixn, pwzName);
ExitOnFailure1(hr, "failed to remove attribute: %ls", pwzName);
}
else
{
// Clear the text value for the node
hr = XmlSetText(pixn, L"");
ExitOnFailure(hr, "failed to clear text value");
}
break;
case xaDeleteElement:
if (NULL != pwzVerifyPath && 0 != pwzVerifyPath[0])
{
hr = XmlSelectSingleNode(pixn, pwzVerifyPath, &pixnVerify);
if (S_OK == hr)
{
hr = pixn->removeChild(pixnVerify, &pixnRemovedChild);
ExitOnFailure(hr, "failed to remove created child element");
ReleaseNullObject(pixnRemovedChild);
}
else
{
WcaLog(LOGMSG_VERBOSE, "Failed to select path %ls for deleting. Skipping...", pwzVerifyPath);
hr = S_OK;
}
}
else
{
// TODO: This requires a VerifyPath to delete an element. Should we support not having one?
WcaLog(LOGMSG_VERBOSE, "No VerifyPath specified for delete element of ID: %ls", pwzElementPath);
}
break;
default:
ExitOnFailure(hr = E_UNEXPECTED, "Invalid modification specified in custom action data");
break;
}
}
// Now that we've made all of the changes to this file, save it and move on to the next
if (S_OK == hrOpenFailure)
{
if (fPreserveDate)
{
hr = FileGetTime(pwzFile, NULL, NULL, &ft);
ExitOnFailure1(hr, "failed to get modified time of file : %ls", pwzFile);
}
示例4: Save
//.........这里部分代码省略.........
*(psz++) = L',';
}
if (bsType && lstrcmp(bsType, L"hex"))
{
// Допустим только "hex"
::SysFreeString(bsType); bsType = NULL;
}
if (!bsType)
{
// нужно добавить/установить тип
bsType = ::SysAllocString(L"hex"); bNeedSetType = true;
}
}
} break;
case REG_SZ:
{
wchar_t* psz = (wchar_t*)value;
bsValue = ::SysAllocString(psz);
if (bsType && lstrcmp(bsType, L"string"))
{
// Допустим только "string"
::SysFreeString(bsType); bsType = NULL;
}
if (!bsType)
{
// нужно добавить/установить тип
bsType = ::SysAllocString(L"string"); bNeedSetType = true;
}
} break;
case REG_MULTI_SZ:
{
if (bsType && lstrcmp(bsType, L"multi"))
{
// Допустим только "multi"
::SysFreeString(bsType); bsType = NULL;
}
if (!bsType)
{
// нужно добавить/установить тип
bsType = ::SysAllocString(L"multi"); bNeedSetType = true;
}
} break;
default:
goto wrap; // не поддерживается
}
if (bNeedSetType)
{
_ASSERTE(bsType!=NULL);
SetAttr(pChild, pAttrs, L"type", bsType);
::SysFreeString(bsType); bsType = NULL;
}
// Теперь собственно значение
if (nType != REG_MULTI_SZ)
{
_ASSERTE(bsValue != NULL);
SetAttr(pChild, pAttrs, L"data", bsValue);
::SysFreeString(bsValue); bsValue = NULL;
}
else // Тут нужно формировать список элементов <list>
{
// Если ранее был параметр "data" - удалить его из списка атрибутов
hr = pAttrs->getNamedItem(L"data", &pNode);
if (SUCCEEDED(hr) && pNode)
{
hr = pChild->removeChild(pNode, &pNodeRmv);
pNode->Release(); pNode = NULL;
SetDataChanged();
if (pNodeRmv) { pNodeRmv->Release(); pNodeRmv = NULL; }
}
long nAllLen = nSize/2; // длина в wchar_t
wchar_t* psz = (wchar_t*)value;
SetMultiLine(pChild, psz, nAllLen);
}
mb_Modified = true;
wrap:
if (pIXMLDOMAttribute) { pIXMLDOMAttribute->Release(); pIXMLDOMAttribute = NULL; }
if (pNode) { pNode->Release(); pNode = NULL; }
if (pNodeRmv) { pNodeRmv->Release(); pNodeRmv = NULL; }
if (pChild) { pChild->Release(); pChild = NULL; }
if (pAttrs) { pAttrs->Release(); pAttrs = NULL; }
if (bsValue) { ::SysFreeString(bsValue); bsValue = NULL; }
if (bsType) { ::SysFreeString(bsType); bsType = NULL; }
}