Share via


IXMLDOMDocument::save

banner art

Previous Next

IXMLDOMDocument::save

The save method saves an XML document to the specified location.

Syntax

  HRESULT save(
 VARIANT varDestination
);

Parameters

varDestination

[in] VARIANT representing a file name. See Remarks.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

The URL scheme and the file name extension identify the data source plug-in and the playlist parser plug-in respectively. Use the URL prefix property, accessible from the IWMSNamedValues collection, to indicate the URL scheme used by the data source plug-in. Use the URL suffix property, accessible from the IWMSNamedValues collection, to specify the file name extension supported by the playlist parser. If no URL is specified, the server defaults to the WMS File Data Source plug-in. To specify a file on a FAT, NTFS, or any CIFS file system, use c:\wmpub\wmroot\movie.xml or file://c:\wmpub\wmroot\movie.xml ("file://" identifies the URL scheme for the WMS File Data Source plug-in). The WMS HTML playlist parser plug-in supports only the .htm file extension.

A saved XML document might not load if the URLs are not accessible from the location in which you saved the document.

UTF-8 character encoding is used when saving a playlist document.

Validation is not performed by the save method.

This method is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

Example Code

The following example saves a newly created XML document to a specified location.

#include "wmsserver.h"
#include <atlbase.h> // Includes CComVariant and CComBSTR.

// Declare variables.
IWMSServer*         pServer;
IXMLDOMDocument*    pPlaylist;

HRESULT             hr;
VARIANT_BOOL        bIsSuccessful;
CComVariant         varFile;
CComBSTR            bstrXML;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer, NULL, CLSCTX_ALL, 
       IID_IWMSServer, (void**)&pServer);
if (FAILED(hr)) goto EXIT;

// Create the playlist object.
hr = pServer->CreatePlaylist(&pPlaylist);

// Add some XML to the new document.
bstrXML = "<?wsx version \"1.0\" ?><smil> \
           <media src = \"welcome1.asf\"/></smil>";
hr = pPlaylist->loadXML(bstrXML, &bIsSuccessful); 
if (FAILED(hr)) goto EXIT;

if (bIsSuccessful)
{
    // Save the playlist file.
    varFile = "c:\\wmpub\\wmroot\\sample.wsx";
    hr = pPlaylist->save(varFile);
    if (FAILED(hr)) goto EXIT;
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

Requirements

Header: wmsserver.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next