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 |
IXMLDOMNode::get_previousSibling
The get_previousSibling method retrieves the previous sibling of this node in the parent's child list.
Syntax
HRESULT get_previousSibling( IXMLDOMNode** ppPreviousSibling );
Parameters
ppPreviousSibling
[out] Pointer to a pointer to an IXMLDOMNode interface containing the previous sibling of this 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 value of the IXMLDOMNode interface retrieved depends on the type of node on which the get_previousSibling method is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, the node which immediately precedes 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_ELEMENT NODE_PROCESSING_INSTRUCTION NODE_TEXT |
Retrieves the node immediately preceding this node in its parent's child list. Returns NULL if no such node exists. |
Example Code
The following example retrieves an IXMLDOMNode interface and sets it to the previous 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* pXMLPrevNode;
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 previous sibling of the current node.
hr = pXMLNodeList->get_item(1, &pXMLCurrNode);
if (FAILED(hr)) goto EXIT;
hr = pXMLCurrNode->get_previousSibling(&pXMLPrevNode);
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 |