Save the Current XML Document to a File 

The example below saves the current XML document to a file specified by the strFilename variable. If strFilename does not contain a file name and path, the document is saved to the file given by class member variable m_strCurrentFile.

if(strFilename.empty())
{
// Save the current document
 CComVariant vXMLCurrent(m_strCurrentFile.c_str());
 hResult = m_pXMLDoc->save(vXMLCurrent);
}
else
{
// Save the current document
 CComVariant vXMLNew(strFilename.c_str());
 hResult = m_pXMLDoc->save(vXMLNew);

// Store the new file name
 m_strCurrentFile = strFilename;
}