IXMLDOMElement.getAttribute (Visual Basic .NET)

The getAttribute method retrieves the value of the attribute.

Variant = IXMLDOMElement.getAttribute(
  strName As String



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

Return Value

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.


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


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

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 sValue As String

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

' Load a playlist.

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

' Retrieve the value for the attribute named "src".
sValue = Elem.getAttribute("src")
Exit Sub

' TODO: Handle errors.


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


IXMLDOMElement Object (Visual Basic .NET)


XML DOM Methods (Visual Basic .NET)