#include "StdAfx.h"
#include "configxml.h"

CConfigXml::CConfigXml(void)
{
}

CConfigXml::~CConfigXml(void)
{
}

void CConfigXml::AddLeaf(MSXML::IXMLDOMDocumentPtr doc, MSXML::IXMLDOMElementPtr node, CString name, CString data)
{
	MSXML::IXMLDOMElementPtr leaf;
	MSXML::IXMLDOMAttributePtr attr;

	leaf = doc->createElement("Leaf");
	attr = doc->createAttribute("key");
	attr->value = _bstr_t(name);
	leaf->setAttributeNode(attr);
	leaf->text = _bstr_t(data);
	node->appendChild(leaf);

	leaf.Release();
	attr.Release();
}

CString CConfigXml::GetAttrv(MSXML::IXMLDOMDocumentPtr doc, MSXML::IXMLDOMElementPtr element, CString name)
{
	//	アトリビュートのチェック
	MSXML::IXMLDOMNamedNodeMapPtr	attrList = element->attributes;
	for(int j=0;j<attrList->length;j++)
	{
		MSXML::IXMLDOMAttributePtr attr = attrList->item[j];
		if(attr->nodeName == _bstr_t(name))
		{
			return(attr->value);
		}
		attr.Release();
	}

	return "";
}
