Share via


IXMLDOMNode.attributes (C#)

banner art

Previous Next

IXMLDOMNode.attributes (C#)

The attributes property contains the list of attributes for this node.

Syntax

  IXMLDOMNamedNodeMap = IXMLDOMNode.attributes;

Remarks

The property is read-only. It returns an IXMLDOMNamedNodeMap object for nodes that can return attributes. It returns NULL for all other node types. For the valid node types, an IXMLDOMNamedNodeMap object is always returned; when there are no attributes on the element, the list length is set to zero.

The value of the IXMLDOMNamedNodeMap object returned depends on the type of node on which the attributes property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, an IXMLDOMNamedNodeMap object is returned containing a list of attribute nodes for that element node.

Node type Value returned
NODE_ATTRIBUTE
NODE_COMMENT
NODE_DOCUMENT
NODE_TEXT
Always returns NULL.
NODE_ELEMENT Returns an IXMLDOMNamedNodeMap object that contains a list of nodes corresponding to the attributes of the element.
NODE_PROCESSING_INSTRUCTION Returns NULL for all processing instructions except the XML declaration; for example:

<?xml version="1.0" encoding="windows-1252" standalone="yes" ?>

For the XML declaration, the version, encoding, and stand-alone specifications can be accessed as attributes from the corresponding node.

Example Code

The following example creates an IXMLDOMNamedNodeMap object from a document's attributes property, and then displays the number of nodes in the object.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNamedNodeMap oNamedNodeMap;

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");

    oNamedNodeMap = Playlist.documentElement.firstChild.attributes;
    MessageBox.Show(oNamedNodeMap.length.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