IXMLDOMAttribute::put_value

The put_value method specifies the attribute value.

HRESULT put_value(
VARIANT* pAttributeValue
);

Arguments

pAttributeValue

[in] Pointer to a VARIANT that contains the value of the attribute.

Return Value

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

Remarks

This method specifies the value of the attribute.

Example

The following example retrieves the value of the first attribute of the document root and assigns it a new value.

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

// Declare variables.
IWMSServer*            pServer;
IXMLDOMAttribute*      pXMLAttribute;
IXMLDOMDocument*       pPlaylist;
IXMLDOMElement*        pXMLElement;

HRESULT                hr;
CComBSTR               bstrName;
CComVariant            varFile;
CComVariant            varValue;
CComVariant            varAttValue;
VARIANT_BOOL           bIsSuccessful;

// 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.
varFile = "c:\\wmpub\\wmroot\\simple.wsx";
hr = pPlaylist->load(varFile, &bIsSuccessful);
if (FAILED(hr)) goto EXIT;

if (bIsSuccessful)
{
    // Retrieve a pointer to an IXMLElement interface.
    hr = pPlaylist->get_documentElement(&pXMLElement);
    if (FAILED(hr)) goto EXIT;

    // Set an attribute associated with the element with
    // the values listed below.
    bstrName = "document";
    varValue = "version 1.0";
    hr = pXMLElement->setAttribute(bstrName, varValue);
    if (FAILED(hr)) goto EXIT;

    // Retrieve the attribute node with the node name "document."
    hr = pXMLElement->getAttributeNode(bstrName, &pXMLAttribute);
    if (FAILED(hr)) goto EXIT;

    // Assign a new value associated with that attribute.
    varAttValue = "version 1.1";
    hr = pXMLAttribute->put_value(varAttValue);
    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

Reference

IXMLDOMAttribute Interface

Concepts

XML DOM Methods (C++)