IXMLDOMNamedNodeMap::nextNode
Previous | Next |
IXMLDOMNamedNodeMap::nextNode
The nextNode method retrieves the next node in the IXMLDOMNamedNodeMap collection.
Syntax
HRESULT nextNode( IXMLDOMNode** ppNextItem );
Parameters
ppNextItem
[out] Pointer to a pointer to an IXMLDOMNode interface containing the next node in the collection, or NULL if there is no next node. This method calls AddRef internally. To avoid memory leaks, you must call Release when you are finished using the interface.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
The iterator initially points before the first node in the list so that the first call to nextNode retrieves the first node in the list.
This method returns NULL when the current node is the last node or there are no items in the list. When the current node is removed from the list, subsequent calls to nextNode return NULL. The iterator must be reset by calling the reset method.
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 IXMLDOMNamedNodeMap interface and uses its nextNode method to iterate through the collection.
#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; // 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 (int i = 0; i < lCount; i++) { hr = pXMLNamedNodeMap->nextNode(&pXMLNode); 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 |