Share via


IXMLDOMElement.setAttributeNode (Visual Basic .NET)

banner art

Previous Next

IXMLDOMElement.setAttributeNode (Visual Basic .NET)

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

Syntax

  IXMLDOMAttribute = IXMLDOMElement
  .setAttributeNode(
  DOMAttribute As IXMLDOMAttribute
)

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.

Imports interop_msxml
Imports Microsoft.WindowsMediaServices.Interop

On Error GoTo Err

' Declare variables.
Dim Server As New WMSServerClass()
Dim Playlist As IXMLDOMDocument
Dim ElemList As IXMLDOMNodeList
Dim Elem As IXMLDOMElement
Dim Node As IXMLDOMNode
Dim NodeAtt As IXMLDOMAttribute

' 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.item(0)

' Convert the first node into an IXMLDOMElement object.
Elem = CType(Node, IXMLDOMElement)

' 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)
Exit Sub

Err:
' TODO: Handle errors.

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