IXMLDOMNamedNodeMap Object (C#)

The IXMLDOMNamedNodeMap object supports iteration through the collection of attribute nodes. For more information, see the Microsoft XML SDK 3.0 documentation available at the Microsoft Web site.

The IXMLDOMNamedNodeMap object supports the following property and methods.




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




Retrieves the attribute with the specified name.


Returns the attribute with the specified namespace and attribute name.


Allows random access to individual nodes within the collection. Read-only.


Returns the next node in the collection.


Removes an attribute from the collection.


Removes the attribute with the specified namespace and attribute name.


Resets the iterator in the collection of attribute nodes.


Adds the supplied node to the collection.

*Denotes an extension to the W3C DOM.


The IXMLNamedNodeMap object is a node collection that allows access by name as well as by index. This collection is typically used for attributes.

The World Wide Web Consortium (W3C) Document Object Model (DOM) definition does not require IXMLDOMNamedNodeMap objects to be maintained in any particular order. Objects contained in an IXMLDOMNamedNodeMap object can also be accessed by an ordinal index, but this is simply to allow convenient enumeration and does not imply that the DOM specifies an order to these nodes. DOM implementations are not required to preserve the node order.

The Microsoft implementation preserves the attributes in the order in which they appear in the source. Additional attributes are added to the end of the list.

Like the node list, however, a named node map 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 following example creates an IXMLDOMNamedNodeMap object and displays the number of attributes in a specific node.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNodeList NodeList;
IXMLDOMNode node;
IXMLDOMNamedNodeMap namedNodeMap;

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

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

    // Load a sample playlist file.

    // Retrieve the first node that matches the query
    // and display the number of attributes in that node.
    NodeList = Playlist.getElementsByTagName("media");
    node = NodeList[0];
    namedNodeMap = node.attributes;
catch (Exception e) {
    // TODO: Handle exceptions.

See Also


IXMLDOMDocument Object (C#)