Exemplo n.º 1
0
		HRESULT XMLHelper::SetAttribute(MSXML2::IXMLDOMNode *pNode, const TCHAR *pAttr, const TCHAR *pVal)
		{
			HRESULT hr = S_FALSE;
			if(pNode && pAttr)
			{
				MSXML2::IXMLDOMElement *pElem = 0;
				hr = pNode->QueryInterface(IID_IXMLDOMElement, reinterpret_cast<void **>(&pElem));
				if(hr == S_OK)
				{
					BSTR attr = SysAllocString(pAttr);
					VARIANTARG varg;
					VariantInit(&varg);
					varg.vt = VT_BSTR;
					varg.bstrVal = SysAllocString(pVal);
					hr = pElem->setAttribute(attr, varg);
					SysFreeString(attr);
					SysFreeString(varg.bstrVal);
					pElem->Release();
				}
			}
			else
			{
				hr = E_INVALIDARG;
			}
			return hr;
		}
Exemplo n.º 2
0
		HRESULT XMLHelper::SetAttribute(MSXML2::IXMLDOMNode *pNode, const TCHAR *pAttr, int val)
		{
			MSXML2::IXMLDOMElement *pElem = 0;
			HRESULT hr = pNode->QueryInterface(IID_IXMLDOMElement, reinterpret_cast<void **>(&pElem));
			if(hr == S_OK)
			{
				BSTR attr = SysAllocString(pAttr);
				VARIANTARG varg;
				VariantInit(&varg);
				varg.vt = VT_BSTR;
				StringBuffer sb;
				sb.appendInt(val);
				varg.bstrVal = SysAllocString(sb);
				hr = pElem->setAttribute(attr, varg);
				if(attr)
				{
					SysFreeString(attr);
					attr = 0;
				}
				if(varg.bstrVal)
				{
					SysFreeString(varg.bstrVal);
					varg.bstrVal = 0;
				}
				pElem->Release();
			}
			return hr;
		}
void NXMLSettings::WriteStandardSetting(MSXML2::IXMLDOMDocument *pXMLDom,
	MSXML2::IXMLDOMElement *pGrandparentNode, const TCHAR *szElementName,
	const TCHAR *szAttributeName, const TCHAR *szAttributeValue)
{
	MSXML2::IXMLDOMElement		*pParentNode = NULL;
	MSXML2::IXMLDOMAttribute	*pa = NULL;
	MSXML2::IXMLDOMAttribute	*pa1 = NULL;
	BSTR						bstr = NULL;
	BSTR						bstr_wsntt = SysAllocString(L"\n\t\t");
	VARIANT						var;

	bstr = SysAllocString(szElementName);
	pXMLDom->createElement(bstr,&pParentNode);
	SysFreeString(bstr);
	bstr = NULL;

	NXMLSettings::AddWhiteSpaceToNode(pXMLDom,bstr_wsntt,pParentNode);

	/* This will form an attribute of the form:
	name="AttributeName" */
	bstr = SysAllocString(L"name");

	var = NXMLSettings::VariantString(szAttributeName);

	pXMLDom->createAttribute(bstr,&pa);
	pa->put_value(var);
	pParentNode->setAttributeNode(pa,&pa1);
	SysFreeString(bstr);
	bstr = NULL;

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

	pa->Release();
	pa = NULL;
	VariantClear(&var);

	bstr = SysAllocString(szAttributeValue);
	pParentNode->put_text(bstr);
	SysFreeString(bstr);
	bstr = NULL;

	SysFreeString(bstr_wsntt);
	bstr_wsntt = NULL;

	NXMLSettings::AppendChildToParent(pParentNode,pGrandparentNode);

	pParentNode->Release();
	pParentNode = NULL;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
		HRESULT XMLHelper::SetAttributeId(MSXML2::IXMLDOMNode *node, const TCHAR *attribute, const Id &id)
		{
			MSXML2::IXMLDOMElement *pElem = 0;
			HRESULT hr = node->QueryInterface(IID_IXMLDOMElement, reinterpret_cast<void **>(&pElem));
			if(hr == S_OK)
			{
				BSTR attr = SysAllocString(attribute);
				VARIANTARG varg;
				VariantInit(&varg);
				varg.vt = VT_BSTR;
				TCHAR buf[128] = {};
				varg.bstrVal = SysAllocStringLen(id.AsHex(buf), 128);
				hr = pElem->setAttribute(attr, varg);
				SysFreeString(attr);
				SysFreeString(varg.bstrVal);
				pElem->Release();
			}
			return hr;
		}
Exemplo n.º 6
0
		HRESULT XMLHelper::SetAttributeI64(MSXML2::IXMLDOMNode *pNode, const TCHAR *pAttr, unsigned __int64 val)
		{
			MSXML2::IXMLDOMElement *pElem = 0;
			HRESULT hr = pNode->QueryInterface(IID_IXMLDOMElement, reinterpret_cast<void **>(&pElem));
			if(hr == S_OK)
			{
				BSTR attr = SysAllocString(pAttr);
				VARIANTARG varg;
				VariantInit(&varg);
				varg.vt = VT_BSTR;
				TCHAR buf[16];
				varg.bstrVal = SysAllocStringLen(loadngo::data::ModelUtils::toHexString(val, buf), 16);
				hr = pElem->setAttribute(attr, varg);
				SysFreeString(attr);
				SysFreeString(varg.bstrVal);
				pElem->Release();
			}
			return hr;
		}