Edward discusses how to set an integer in the MSXML APIs in this thread. I wanted to provide the snippet of code necessary to do this on an attribute, using the very awesome wrappers generated by the Visual C++ #import directive.
The catch is that becausae a VARIANT is passed in, you can actually use other variant types that can be converted to a string. Here it goes.
MSXML2::IXMLDOMElementPtr the_element = the_document->createElement(L"doc");
the_document->documentElement = the_element;
// <doc attribute="3"/>
std::wcout << L"XML:" << std::endl << the_document->xml;
Note that all interfaces will be released, and even the BSTR returned by the xml property is wrapper in a _bstr_t, so it's released when it goes out of scope. In fact, the extra pair of curly braces are there to make sure that everything gets release before the call to CoUninitialize.