Share via


IXMLDOMNode Interface

banner art

Previous Next

IXMLDOMNode Interface

The IXMLDOMNode interface provides methods that represent the core functionality of any node. For more information, see the Microsoft XML SDK 3.0 documentation available at the Microsoft Web site.

In addition to the methods inherited from the IDispatch interface, the IXMLDOMNode interface exposes the following methods.

Method Description
appendChild Appends the supplied new child as the last child of this node.
cloneNode Creates a new node that is an exact clone of this node.
get_attributes Retrieves the list of attributes for this node.
get_childNodes Retrieves a node list containing the children (for nodes that can have children).
get_firstChild Retrieves the first child of this node.
get_lastChild Retrieves the last child node.
get_nextSibling Retrieves the next sibling of this node in the parent's child list.
get_nodeName Retrieves the qualified name of the element, attribute, or entity reference, or a fixed string for other node types.
get_nodeType Specifies the XML DOM node type, which determines valid values and whether the node can have child nodes.
get_nodeTypeString* Retrieves the node type in string form.
get_nodeValue Retrieves the text associated with the node.
get_ownerDocument Retrieves the root of the document that contains this node.
get_parentNode Retrieves the parent node (for nodes that can have parents).
get_previousSibling Retrieves the left sibling of this node.
hasChildNodes Retrieves a Boolean value indicating whether this node has children.
insertBefore Inserts a child node to the left of the specified node or at the end of the list.
put_nodeValue Specifies the text associated with the node; the text that is associated depends on the node type.
removeChild Removes the specified child node from the list of children and returns it.
replaceChild Returns the specified old child node and replaces it with the supplied new child node.

* Denotes an extension to the W3C DOM.

Example Code

The following example retrieves a pointer to an IXMLDOMNode interface and retrieves the name for that node.

#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              bstrName;
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 name.
    hr = pXMLNodeList->get_item(0, &pXMLNode);
    if (FAILED(hr)) goto EXIT;
    hr = pXMLNode->get_nodeName(&bstrName);
    if (FAILED(hr)) goto EXIT;
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Previous Next