Share via


IXMLDOMNode::get_nextSibling

banner art

Previous Next

IXMLDOMNode::get_nextSibling

The get_nextSibling method retrieves the next sibling of this node in the parent's child list.

Syntax

  HRESULT get_nextSibling(
 IXMLDOMNode** ppNextSibling
);

Parameters

ppNextSibling

[out] Pointer to a pointer to an IXMLDOMNode interface representing the next sibling of the current 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

This method retrieves the next sibling of the current node.

The value of the IXMLDOMNode interface retrieved depends on the type of node on which the get_nextSibling property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, the next node following that element node is retrieved.

Node Type Value retrieved
NODE_ATTRIBUTE
NODE_DOCUMENT
Always returns NULL; these node types do not appear as children of any other nodes.
NODE_COMMENT
NODE_ELEMENT
NODE_PROCESSING_INSTRUCTION
NODE_TEXT
Retrieves a pointer to the node immediately following this node in the list of children of this node's parent. If no such node exists, it returns NULL.

Example Code

The following example retrieves a pointer to an IXMLDOMNode interface and sets it to the next sibling of the current node.

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

// Declare variables.
IWMSServer*           pServer;
IXMLDOMDocument*      pPlaylist;
IXMLDOMElement*       pXMLElement;
IXMLDOMNodeList*      pXMLNodeList;
IXMLDOMNode*          pXMLCurrNode;
IXMLDOMNode*          pXMLNextNode;

HRESULT               hr;
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.
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 IXMLNodeList interface.
    hr = pXMLElement->get_childNodes(&pXMLNodeList);
    if (FAILED(hr)) goto EXIT;

    // Get the first node in the node list and 
    // use it to access the next sibling of the current node.
    hr = pXMLNodeList->get_item(0, &pXMLCurrNode);
    if (FAILED(hr)) goto EXIT;
    hr = pXMLCurrNode->get_nextSibling(&pXMLNextNode);
    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