IXMLDOMElement.getAttribute (C#)

banner art

Previous Next

IXMLDOMElement.getAttribute (C#)

The getAttribute method retrieves the value of the attribute.

Syntax

  object = IXMLDOMElement
  .getAttribute(
  string strName
);

Parameters

strName

[in] string specifying the name of the attribute to return.

Return Values

Returns a string that contains the attribute value or returns the empty string if the named attribute does not have a specified or default value.

Remarks

You can also retrieve attributes by using the getNamedItem method of the IXMLDOMNamedNodeMap object.

Example Code

The following example retrieves the value of an attribute named "src" using the getAttribute method.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNodeList ElemList;
IXMLDOMElement Elem;
IXMLDOMNode Node;
object oValue;

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 a list of nodes that matches the query.
    ElemList = Playlist.getElementsByTagName("media");

    // Retrieve the first node in the list.
    Node = ElemList[0];

    // Box the first node into an IXMLDOMElement object.
    Elem = (IXMLDOMElement)Node;

    // Retrieve the value for the attribute named "src".
    oValue = Elem.getAttribute("src");
}
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