IXMLDOMAttribute::get_name
Previous | Next |
IXMLDOMAttribute::get_name
The get_name method retrieves the attribute name.
Syntax
HRESULT get_name( BSTR* bstrAttributeName );
Parameters
bstrAttributeName
[out] Pointer to a BSTR containing the name of the attribute. The value is the same as the get_nodeName method of the IXMLDOMNode interface.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
It retrieves the name of the attribute. The retrieved bstrAttributeName value is the same as the bstrName value of the get_nodeName method.
Example Code
The following example retrieves a pointer to an IXMLDOMAttribute interface from an attribute created for the root element, and then retrieves its name.
#include "wmsserver.h" #include <atlbase.h> // Includes CComVariant and CComBSTR. // Declare variables. IWMSServer* pServer; IXMLDOMAttribute* pXMLAttribute; IXMLDOMDocument* pPlaylist; IXMLDOMElement* pXMLElement; HRESULT hr; CComBSTR bstrAttName; CComBSTR bstrName; CComVariant varFile; CComVariant varValue; 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 name associated with that attribute. hr = pXMLAttribute->get_name(&bstrAttName); 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 |