IXMLDOMNode.nodeValue (C#)

banner art

Previous Next

IXMLDOMNode.nodeValue (C#)

The nodeValue property contains the text associated with the node.

Syntax

  object = IXMLDOMNode.nodeValue;
IXMLDOMNode.nodeValue = object;

Remarks

The property is read/write.

Setting or returning the value of the object depends on the type of node on which the nodeValue property is called, as shown in the following table. For example, if the node type is NODE_ATTRIBUTE, either an object is returned containing a string representing the value for that attribute node or an object containing a string sets the value for the attribute node.

Node type Value returned or set
NODE_ATTRIBUTE Contains a string representing the value of the attribute. For attributes with subnodes, this is the concatenated text of all subnodes with entities expanded. Setting this value deletes all children of the node and replaces them with a single text node containing the value written.
NODE_COMMENT Contains the content of the comment, exclusive of the comment's start and end sequence.
NODE_ELEMENT, NODE_DOCUMENT Returns NULL. Attempting to set the value of nodes of these types generates an error.
NODE_PROCESSING_INSTRUCTION Contains the processing instruction, excluding the target. (The target appears in the nodeName property.)
NODE_TEXT Contains a string representing the text stored in the text node.

Example Code

The following example creates an IXMLDOMNode object and tests whether it is a comment node. If it is, its value is displayed.

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 value if the node type is NODE_COMMENT.
    currNode = Playlist.documentElement.childNodes[0];
    if (currNode.nodeTypeString == "comment")
        MessageBox.Show(currNode.nodeValue.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