Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
IXMLDOMAttribute::get_value
The get_value method retrieves the attribute value.
Syntax
HRESULT get_value( VARIANT* varAttributeValue );
Parameters
varAttributeValue
[out] Pointer to a VARIANT containing the value of the attribute.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
This method retrieves the value of the attribute.
Example Code
The following example retrieves the value of the first attribute of the document root and assigns it to the variable varAttValue.
#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;
// Retrieve the value associated with that attribute.
hr = pXMLAttribute->get_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
| Previous | Next |