Share via


IXMLDOMDocument::loadXML

banner art

Previous Next

IXMLDOMDocument::loadXML

The loadXML method loads the supplied string into an XML document.

Syntax

  HRESULT loadXML(
 BSTR bstrXML, 
 VARIANT_BOOL* varIsSuccessful
);

Parameters

bstrXML

[in] BSTR containing XML to load into this XML document object. This string can contain an entire XML document or a well-formed fragment.

bIsSuccessful

[out] Pointer to a VARIANT_BOOL indicating whether the load was successful. If the load is unsuccessful, the get_documentElement method of the IXMLDOMDocument interface will return NULL.

Return Values

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

Remarks

Calling load or loadXML on an existing document immediately discards the content of the document. The loadXML method will work only with UTF-8 encodings.

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

Example Code

The following example retrieves a pointer an IXMLDOMDocument interface, and then uses its loadXML method to load the specified XML file.

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

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

HRESULT             hr;
VARIANT_BOOL        bIsSuccessful;
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);

// Load a sample playlist file.
bstrXML = "<?wsx version \"1.0\" ?><smil> \
           <media src = \"welcome1.asf\"/></smil>";
hr = pPlaylist->loadXML(bstrXML, &bIsSuccessful);

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.
if (FAILED(hr)) goto EXIT;

Requirements

Header: wmsserver.h.

Library: WMSServerTypeLib.dll.

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

See Also

Previous Next