Partager via


IXMLDOMNamedNodeMap Object (Visual Basic .NET)

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.

Property

Description

length

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

Method

Description

getNamedItem

Retrieves the attribute with the specified name.

getQualifiedItem*

Returns the attribute with the specified namespace and attribute name.

item

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

nextNode

Returns the next node in the collection.

removeNamedItem

Removes an attribute from the collection.

removeQualifiedItem

Removes the attribute with the specified namespace and attribute name.

reset

Resets the iterator in the collection of attribute nodes.

setNamedItem

Adds the supplied node to the collection.

* Denotes an extension to the W3C DOM.

Remarks

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.

Example

The following example creates an IXMLDOMNamedNodeMap object and displays the number of attributes in a specific node.

Imports interop_msxml
Imports Microsoft.WindowsMediaServices.Interop

On Error GoTo Err

' Declare variables.
Dim Server As New WMSServerClass()
Dim Playlist As IXMLDOMDocument
Dim node As IXMLDOMNode
Dim nodeList As IXMLDOMNodeList
Dim namedNodeMap As IXMLDOMNamedNodeMap

' Create a new playlist object.
Set Playlist = Server.CreatePlaylist

' Load a sample playlist file.
Playlist.Load "file://c:\wmpub\wmroot\simple.wsx"

' Retrieve the first node that matches the query
' and display the number of attributes in that node.
nodeList = Playlist.getElementsByTagName("media")
node = nodeList.item(0)
namedNodeMap = node.attributes
MsgBox (namedNodeMap.length.ToString())
Exit Sub

Err:
' TODO: Handle errors.

See Also

Reference

IXMLDOMDocument Object (Visual Basic .NET)