用MSXML为xml添加属性

前端之家收集整理的这篇文章主要介绍了用MSXML为xml添加属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
VOID XXX_XML()
{
	IXMLDOMDocumentPtr pXmlDocument;
	if ( pXmlDocument.CreateInstance(__uuidof(XML::DOMDocument)) != S_OK )
	{
		return;
	}
	// Do load
	IXMLDOMElementPtr xmlNode = pXmlDocument->selectSingleNode(_bstr_t("PROGRAM/INFO/SECTION"));

	WCHAR* strFiled[2] = {L"strBaseVer",L"strRemark"};
	for (int id = 0; id < 2; id++)
	{
		IXMLDOMAttributePtr paA = NULL;
		_bstr_t bstrA = SysAllocString(strFiled[id]);
		paA = pXmlDocument->createAttribute(bstrA); 
		VARIANT vrValue = (_variant_t)(_bstr_t)(L"noused");
		paA->put_value(vrValue);
		xmlNode->setAttributeNode(paA);
	}
	return;
}

猜你在找的XML相关文章