Exemple #1
0
		HRESULT XMLHelper::CreateNode(MSXML2::IXMLDOMDocument2 *doc, MSXML2::IXMLDOMNode *parent, MSXML2::IXMLDOMNode **newNode, const TCHAR *name)
		{
			HRESULT hr = S_OK;
			bool release = false;
			if(!parent)
			{
				MSXML2::IXMLDOMElement *element = 0;
				hr = doc->get_documentElement(&element);
				if(hr == S_OK)
				{
					hr = element->QueryInterface(IID_IXMLDOMNode, reinterpret_cast<void **>(&parent));
				}
				release = true;
			}
			if(hr == S_OK && parent)
			{
				hr = XMLHelper::CreateChild(parent, newNode, name);
			}
			if(release)
			{
				parent->Release();
				parent = 0;
			}
			return hr;
		}
MSXML2::IXMLDOMNode * RecurrenceManager::GetRecurrencesNode()
{
	MSXML2::IXMLDOMNode *pNode = 0;
	MSXML2::IXMLDOMElement *pRoot = 0;
	HRESULT hr = m_pXMLDoc->get_documentElement(&pRoot);
	BSTR xpath = SysAllocString(_T("//recurrences"));
	hr = m_pXMLDoc->selectSingleNode(xpath, reinterpret_cast<MSXML2::IXMLDOMNode **>(&pNode));
	SysFreeString(xpath);
	if(hr == S_FALSE)
	{
		MSXML2::IXMLDOMNode *pRootNode = 0;
		pRoot->QueryInterface(IID_IXMLDOMNode, reinterpret_cast<void **>(&pRootNode));
		XMLHelper::CreateChild(pRootNode, &pNode, _T("recurrences"));
		pRootNode->Release();
	}
	pRoot->Release();
	return pNode;
}