예제 #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;
		}
예제 #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;
		}
예제 #3
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;
		}
예제 #4
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;
		}