void NXMLSettings::AddAttributeToNode(MSXML2::IXMLDOMDocument *pXMLDom,
MSXML2::IXMLDOMElement *pParentNode,const WCHAR *wszAttributeName,
const WCHAR *wszAttributeValue)
{
	MSXML2::IXMLDOMAttribute	*pa = NULL;
	MSXML2::IXMLDOMAttribute	*pa1 = NULL;
	BSTR						bstr = NULL;
	VARIANT						var;

	bstr = SysAllocString(wszAttributeName);

	var = VariantString(wszAttributeValue);

	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);
}
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;
}