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


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

本文整理汇总了C++中IXMLDOMNode::put_text方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::put_text方法的具体用法?C++ IXMLDOMNode::put_text怎么用?C++ IXMLDOMNode::put_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IXMLDOMNode的用法示例。


在下文中一共展示了IXMLDOMNode::put_text方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetAttr

bool SettingsXML::SetAttr(IXMLDOMNode* apNode, IXMLDOMNamedNodeMap* apAttrs, const wchar_t* asName, const wchar_t* asValue)
{
	bool lbRc = false;
	HRESULT hr = S_OK;
	IXMLDOMNode *pValue = NULL;
	IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
	BSTR bsText = NULL;
	bsText = ::SysAllocString(asName);
	hr = apAttrs->getNamedItem(bsText, &pValue);

	BSTR bsValue = ::SysAllocString(asValue);
	wchar_t* pszEsc = wcschr(bsValue, (wchar_t)27);
	if (pszEsc != NULL)
	{
		_ASSERTE(wcschr(bsValue, (wchar_t)27) == NULL); // У DOM сносит крышу, если писать "ESC" в значение
		while ((pszEsc = wcschr(bsValue, (wchar_t)27)) != NULL)
		{
			*pszEsc = L'?';
		}
	}

	if (FAILED(hr) || !pValue)
	{
		hr = mp_File->createAttribute(bsText, &pIXMLDOMAttribute);
		_ASSERTE(hr == S_OK);

		if (SUCCEEDED(hr) && pIXMLDOMAttribute)
		{
			VARIANT vtValue; vtValue.vt = VT_BSTR; vtValue.bstrVal = bsValue;
			hr = pIXMLDOMAttribute->put_nodeValue(vtValue);
			_ASSERTE(hr == S_OK);
			hr = apAttrs->setNamedItem(pIXMLDOMAttribute, &pValue); //-V519
			_ASSERTE(hr == S_OK);
			lbRc = SUCCEEDED(hr);
		}
	}
	else if (SUCCEEDED(hr) && pValue)
	{
		hr = pValue->put_text(bsValue);
		_ASSERTE(hr == S_OK);
		lbRc = SUCCEEDED(hr);
	}

	::SysFreeString(bsText); bsText = NULL;
	::SysFreeString(bsValue); bsValue = NULL;

	if (pValue) { pValue->Release(); pValue = NULL; }

	if (pIXMLDOMAttribute) { pIXMLDOMAttribute->Release(); pIXMLDOMAttribute = NULL; }

	return lbRc;
}
开发者ID:mirror,项目名称:conemu,代码行数:52,代码来源:Registry.cpp

示例2: AppendText

void SettingsXML::AppendText(IXMLDOMNode* apFrom, BSTR asText)
{
	if (!asText || !*asText)
		return;

	VARIANT vtType;
	IXMLDOMNode* pChild = NULL;
	IXMLDOMNode *pIXMLDOMNode = NULL;
	vtType.vt = VT_I4; vtType.lVal = NODE_TEXT;
	HRESULT hr = mp_File->createNode(vtType, L"", L"", &pChild);

	if (SUCCEEDED(hr) && pChild)
	{
		hr = pChild->put_text(asText);
		hr = apFrom->appendChild(pChild, &pIXMLDOMNode); //-V519
		pChild->Release(); pChild = NULL;

		if (SUCCEEDED(hr) && pIXMLDOMNode)
		{
			pIXMLDOMNode->Release(); pIXMLDOMNode = NULL;
		}
	}
}
开发者ID:huyiice,项目名称:ConEmu,代码行数:23,代码来源:Registry.cpp

示例3: SetModified

HRESULT
CIhvProfileBase::PutTextInNode
(
    IN  LPCWSTR         pszQuery,
    IN  BSTR            bstrText
)
{
    HRESULT         hr          =   S_OK;
    BSTR            bstrQuery   =   NULL;
    BSTR            bstrOrig    =   NULL;
    BOOL            bPut        =   TRUE;
    IXMLDOMNode*    pQueryNode  =   NULL;

    if ( !m_pRootNode )
    {
        hr = E_UNEXPECTED;
        BAIL_ON_FAILURE( hr );
    }

    if ( (!pszQuery) || (!bstrText) )
    {
        hr = E_INVALIDARG;
        BAIL_ON_FAILURE( hr );
    }

    hr =
    Wstr2Bstr
    (
        pszQuery,
        &bstrQuery
    );
    BAIL_ON_FAILURE( hr );

    hr = m_pRootNode->selectSingleNode( bstrQuery, &pQueryNode );
    BAIL_ON_FAILURE( hr );

    if (!pQueryNode)
    {
        hr = E_UNEXPECTED;
        BAIL_ON_FAILURE( hr );
    }

    hr = pQueryNode->get_text( &bstrOrig );
    BAIL_ON_FAILURE( hr );

    if ( bstrOrig && ( 0 == wcscmp( bstrOrig, bstrText ) ) )
    {
        bPut = FALSE;
    }

    if ( bPut )
    {
        hr = pQueryNode->put_text( bstrText );
        BAIL_ON_FAILURE( hr );

        SetModified( );
    }

error:
    RELEASE_INTERFACE( pQueryNode );
    SYS_FREE_STRING( bstrQuery );
    SYS_FREE_STRING( bstrOrig  );
    return hr;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:64,代码来源:IHVSampleProfile.cpp

示例4: CreateElement

/*
	 Function name		: CXML::CreateElement
	 Description	    : This function create an element node set it as the current Node
						: with attributes and value and the text supplied 
	 Return type		: bool 
	 Argument			: IXMLDOMNode **ppRemoveNode
 */	
bool CXML::CreateElement(CString csTagName,LPCTSTR lpszText,char ** ppAttributes,char ** ppValues,int nNoOfAttributes,bool bSetAsCurNode)
{
	IXMLDOMNode * pNode = NULL;
	if(csTagName.IsEmpty())
		return false;

	if(!m_pICurrentNode)
		return false;

	_variant_t vtNodeType((long)NODE_ELEMENT);
	_bstr_t bstrName(csTagName);
	_bstr_t bstrNameSpace("");

	m_hr = m_pXMLDoc->createNode(vtNodeType,bstrName,bstrNameSpace,&pNode);
	if(!SUCCEEDED(m_hr))
		return false;

	if(m_pINewElement)
	{
		m_pINewElement->Release();
		m_pINewElement = NULL;
	}


	if(!AddNode(&m_pICurrentNode,&pNode,&m_pINewElement,NODE_ELEMENT))
	{
		pNode->Release();
		return false;
	} 

	if(!m_pINewElement)
		return false;

	if(lpszText)
	{
		_bstr_t bstrData(lpszText);

		m_hr = pNode->put_text(bstrData);
		if(!SUCCEEDED(m_hr))
		{
			pNode->Release();
			return false;
		}
	}

	pNode->Release();

	if(nNoOfAttributes && ppAttributes && ppValues )
	{
		for(int i = 0;i<nNoOfAttributes;++i)
		{
			if(!CreateAttributeNode(&m_pINewElement,ppAttributes[i],ppValues[i]))
				return false;
		}
	}

	if(bSetAsCurNode)
	{
		if(m_pICurrentNode)
		{
			m_pICurrentNode->Release();
			m_pICurrentNode = NULL;

		}
		m_pICurrentNode = m_pINewElement;
		m_pICurrentNode->AddRef();
	}
	return true;
}
开发者ID:alexcpn,项目名称:TelephonyIVRKeyMapDemo,代码行数:76,代码来源:XML.cpp


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