Share via


IXMLDOMElement.setAttributeNode (C#)

banner art

Previous Next

IXMLDOMElement.setAttributeNode (C#)

The setAttributeNode method sets or updates the supplied attribute node on this element.

Syntax

  IXMLDOMAttribute = IXMLDOMElement
  .setAttributeNode(
  IXMLDOMAttribute DOMAttribute
);

Parameters

DOMAttribute

[in] IXMLDOMAttribute object that contains the attribute node to be associated with this element.

Return Values

Returns NULL unless the new attribute replaces an existing attribute with the same name, in which case this method returns the previous, replaced attribute node.

Example Code

The following example creates an attribute node and adds it to the specified element node.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMNodeList ElemList;
IXMLDOMElement Elem;
IXMLDOMNode Node;
IXMLDOMAttribute NodeAtt;

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;

    // Create a new attribute and assign it a value.
    NodeAtt = Playlist.createAttribute("dur");
    NodeAtt.value = ("15s");

    // Add the attribute object named "dur" to the element.
    Elem.setAttributeNode(NodeAtt);
}
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