Share via


IXMLDOMNode::get_nodeTypeString

banner art

Previous Next

IXMLDOMNode::get_nodeTypeString

The get_nodeTypeString method retrieves the node type in string form.

Syntax

  HRESULT get_nodeTypeString(
 BSTR* bstrNodeType
);

Parameters

bstrNodeType

[out] Pointer to a BSTR containing the version of the node type.

Return Values

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

Remarks

This method retrieves the string version of the node type. To retrieve the enumeration value, use the get_nodeType method.

The value of the BSTR retrieved depends on the type of node on which the get_nodeTypeString method is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, the word "element" is retrieved.

Node type Value retrieved
NODE_ATTRIBUTE Retrieves the literal string "attribute".
NODE_COMMENT Retrieves the literal string "comment".
NODE_DOCUMENT Retrieves the literal string "document".
NODE_ELEMENT Retrieves the literal string "element".
NODE_PROCESSING_INSTRUCTION Retrieves the literal string "processinginstruction".
NODE_TEXT Retrieves the literal string "text".

Example Code

The following example retrieves a pointer an IXMLDOMNode interface and retrieves its node type in string form, in this case, "element".

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

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

HRESULT               hr;
CComVariant           varValue;
CComBSTR              bstrType;
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 
    // retrieve the node type.
    hr = pXMLNodeList->get_item(0, &pXMLNode);
    if (FAILED(hr)) goto EXIT;
    hr = pXMLNode->get_nodeTypeString(&bstrType);
    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