IXMLDOMNodeList.item (C#)

banner art

Previous Next

IXMLDOMNodeList.item (C#)

The item method allows random access to individual nodes within the IXMLDOMNodeList collection.

Syntax

  IXMLDOMNode = IXMLDOMNodeList
  [
  int lIndex
];

Parameters

lIndex

[in] int containing the index of the item within the collection. The first item is zero.

Return Values

Returns an IXMLDOMNode object. Returns NULL if the index is out of range.

Example Code

The following example creates an IXMLDOMNodeList object with the document's getElementsByTagName method. It then iterates through the collection displaying the node value for each item 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 playlist.
    playlist.load(("file://c:\\wmpub\\wmroot\\simple.wsx"));

    // Retrieve all the elements with the tag name "media".
    NodeList = Playlist.getElementsByTagName("media");

    // Display the node value for every node in the list.
    for(int i = 0; i < NodeList.length; i++)
    {
        MessageBox.Show(NodeList[i].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