IXMLDOMNode::get_nodeType

The get_nodeType method retrieves the XML Document Object Model (DOM) node type, which determines whether the node can have child nodes and what types of child nodes it can have.

HRESULT get_nodeType(
DOMNodeType* pType
);

Arguments

pType

[out] Pointer to a DOMNodeType enumeration representing the type of the node.

Return Value

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

Remarks

This method indicates the type of the node. Use the get_nodeTypeString method to retrieve the node type in string form. The following table describes the possible values for the pType parameter.

Node Type

Description

NODE_ELEMENT (1)

The node represents an element. An element node can have the following child node types: Element, and ProcessingInstruction. An element node can be the child of the document and element nodes.

NODE_ATTRIBUTE (2)

The node represents an attribute of an element. An attribute does not appear as the child node of any other node type; it is not considered a child node of an element.

NODE_TEXT (3)

The node represents the text content of a tag. A text node cannot have any child nodes. A text node can appear as the child node of the Attribute and Element nodes.

NODE_PROCESSING_INSTRUCTION (7)

The node represents a processing instruction from the XML document. A processing instruction node cannot have any child nodes. A processing instruction node can appear as the child of the Document and Element nodes.

NODE_COMMENT (8)

The node represents a comment in the XML document. A comment node cannot have any child nodes. A comment node can appear as the child of Document and Element nodes.

NODE_DOCUMENT (9)

The node represents a document object, which, as the root of the document tree, provides access to the entire XML document. A document node can have the following child node types: Element (maximum of one), and ProcessingInstruction. A document node cannot appear as the child of any node types.

Example

The following example retrieves a pointer to an IXMLDOMNodeIXMLDOMNode Interface and retrieves its type enumeration, in this case, 1 for NODE_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;
DOMNodeType           ntValue;
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_nodeType(&ntValue);
    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

Reference

IXMLDOMNode Interface

Concepts

XML DOM Methods (C++)