Partager via


IXMLDOMNodeList Object (C#)

The IXMLDOMNodeList object supports iteration through the live collection, in addition to indexed access. For more information, see the Microsoft XML SDK 3.0 documentation available at the Microsoft Web site.

The IXMLDOMNodeList object supports the following property and methods.

Property

Description

length

Indicates the number of items in the collection. Read-only.

Method

Description

item

Allows random access to individual nodes within the collection.

nextNode*

Returns the next node in the collection.

reset*

Resets the iterator in the collection of nodes.

*Denotes an extension to the W3C DOM.

Remarks

A node list collection is live; that is, the addition and removal of nodes, and changes within nodes, are immediately reflected in the collection. This means that two successive requests for items using the same index can return two different items, depending on changes to the collection. This also means that changes to the node objects are immediately available in the nodes obtained from the list. The collection can also be accessed using the "for...next" construct.

Example

The following example creates an IXMLDOMNodeList object and displays the number of nodes in the list.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNodeList nodeList;

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

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

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

    // Retrieve all elements with the node name "smil".
    nodeList = Playlist.getElementsByTagName("smil");

    // Display the total number of nodes in the list.
    MessageBox.Show(nodeList.length.ToString());
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

See Also

Reference

IXMLDOMDocument Object (C#)