IXMLDOMNode.nodeName (C#)

banner art

Previous Next

IXMLDOMNode.nodeName (C#)

The nodeName property contains the qualified name of the element, attribute, or entity reference, or a fixed string for other node types.

Syntax

  string = IXMLDOMNode.nodeName;

Remarks

The property is read-only and always contains a non-empty string. The nodeName property contains the name for the element, attribute, or entity reference.

The value of the string returned depends on the type of node on which the nodeName property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, a string is returned containing the name of the XML tag for that element node.

Node type Value returned
NODE_ATTRIBUTE Contains the name of the attribute.
NODE_COMMENT Contains the literal string "#comment".
NODE_DOCUMENT Contains the literal string "#document".
NODE_ELEMENT Contains the name of the XML tag, with any namespace prefix included if present.
NODE_PROCESSING_INSTRUCTION Contains the target (the first token following the <? characters).
NODE_TEXT Contains the literal string "#text".

Example Code

The following example creates an IXMLDOMNode object and displays its name.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNode currNode;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Create a new playlist object.
    Playlist = Server.CreatePlaylist();

    // Load a playlist.
    Playlist.load("file://c:\\wmpub\\wmroot\\simple.wsx");

    // Retrieve the first child node of the root element and 
    // display its node name.
    currNode = Playlist.documentElement.childNodes[0];
    MessageBox.Show(currNode.nodeName.ToString());
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

Requirements

Reference: Add references to Microsoft.WindowsMediaServices and interop_msxml.

Namespace: Microsoft.WindowsMediaServices.Interop, interop_msxml.

Assembly: Microsoft.WindowsMediaServices.dll, interop_msxml.dll.

Library: WMSServerTypeLib.dll, msxml.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next