Share via


IXMLDOMNodeList::reset

banner art

Previous Next

IXMLDOMNodeList::reset

The reset method resets the iterator in the collection of 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 reinitializes the iterator to point before the first node in the node list so that the next call to nextNode retrieves the first item in the list.

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

Example Code

The following example retrieves a pointer to an IXMLDOMNodeList interface and iterates the collection using the nextNode method. It then uses the reset method to reset the iterator to point before the first node in the list.

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

// Declare variables.
IWMSServer*         pServer;
IXMLDOMDocument*    pPlaylist;
IXMLDOMNodeList*    pXMLNodeList;
IXMLDOMNode*        pXMLNode;

HRESULT             hr;
VARIANT_BOOL        bIsSuccessful;
CComBSTR            bstrName;
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 list of media elements.
    bstrName = "media";
    hr = pPlaylist->getElementsByTagName(bstrName, &pXMLNodeList);
    if (FAILED(hr)) goto EXIT;

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

    // Retrieve each element in the list.
    for(long i = 0; i < lCount; i++)
    {
        hr = pXMLNodeList->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 = pXMLNodeList->reset();
    if (FAILED(hr)) goto EXIT;
    hr = pXMLNodeList->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