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 |
IXMLDOMNamedNodeMap::get_length
The get_length method indicates the number of items in the IXMLDOMNamedNodeMap collection.
Syntax
HRESULT get_length( long* lListLength );
Parameters
lListLength
[out] Pointer to a long representing the number of items in the collection.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Example Code
The following example retrieves a pointer to an IXMLDOMNamedNodeMap interface and then uses its get_length method to support iteration.
#include "wmsserver.h"
#include <atlbase.h> // Includes CComVariant and CComBSTR.
// Declare variables.
IWMSServer* pServer;
IXMLDOMDocument* pPlaylist;
IXMLDOMElement* pXMLElement;
IXMLDOMNamedNodeMap* pXMLNamedNodeMap;
IXMLDOMNode* pXMLNode;
HRESULT hr;
CComBSTR bstrText;
CComVariant varAttValue;
CComVariant varValue;
VARIANT_BOOL bIsSuccessful;
long lCount;
// 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.
varValue = "c:\\wmpub\\wmroot\\simple.wsx";
hr = pPlaylist->load(varValue, &bIsSuccessful);
if (FAILED(hr)) goto EXIT;
if (bIsSuccessful)
{
// Retrieve a pointer to the IXMLDOMElement interface.
hr = pPlaylist->get_documentElement(&pXMLElement);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to the IXMLDOMNamedNodeMap interface.
hr = pXMLElement->get_attributes(&pXMLNamedNodeMap);
if (FAILED(hr)) goto EXIT;
// Retrieve the total count of attributes.
hr = pXMLNamedNodeMap->get_length(&lCount);
if (FAILED(hr)) goto EXIT;
// Display the node value associated with each attribute
// in the collection.
for (int i = 0; i < lCount; i++)
{
hr = pXMLNamedNodeMap->get_item(i, &pXMLNode);
if (FAILED(hr)) goto EXIT;
hr = pXMLNode->get_nodeValue(&varAttValue);
if (FAILED(hr)) goto EXIT;
// Release temporary COM objects.
pXMLNode->Release();
}
}
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 |