Share via


IXMLDOMNamedNodeMap::reset

banner art

Previous Next

IXMLDOMNamedNodeMap::reset

The reset method resets the iterator to the beginning of the collection of attribute nodes.

Syntax

  HRESULT reset();

Parameters

This method takes no parameters.

Return Values

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

Remarks

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

Example Code

The following example uses the reset method to reset the iterator in the list of attributes so that the nextNode method will return the first node in the list.

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

// Declare variables.
IWMSServer*          pServer;
IXMLDOMDocument*     pPlaylist;
IXMLDOMElement*      pXMLElement;
IXMLDOMNamedNodeMap* pXMLNamedNodeMap;
IXMLDOMNode*         pXMLNode;

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

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

    // Retrieve a pointer to an IXMLDOMNamedNodeMap interface.
    hr = pXMLElement->get_attributes(&pXMLNamedNodeMap);
    if (FAILED(hr)) goto EXIT;

    // Retrieve the number of nodes in the list.
    hr = pXMLNamedNodeMap->get_length(&lCount);
    if (FAILED(hr)) goto EXIT;

    // Retrieve each node in the list.
    for(long i = 0; i < lCount; i++)
    {
        hr = pXMLNamedNodeMap->nextNode(&pXMLNode);
        if (FAILED(hr)) goto EXIT;
    }

    // Reset the iterator so that the following
    // call to nextNode() returns the first node
    // in the list.
    hr = pXMLNamedNodeMap->reset();
    if (FAILED(hr)) goto EXIT;
    hr = pXMLNamedNodeMap->nextNode(&pXMLNode);
    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