当前位置: 首页>>代码示例>>C++>>正文


C++ IXMLDOMNode::removeChild方法代码示例

本文整理汇总了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;
}
开发者ID:alexcpn,项目名称:TelephonyIVRKeyMapDemo,代码行数:27,代码来源:XML.cpp

示例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);
}
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:91,代码来源:COpcXmlDocument.cpp

示例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);
            }
开发者ID:BMurri,项目名称:wix3,代码行数:66,代码来源:XmlConfig.cpp

示例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; }
}
开发者ID:huyiice,项目名称:ConEmu,代码行数:101,代码来源:Registry.cpp


注:本文中的IXMLDOMNode::removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。