Share via


IXMLDOMElement.getElementsByTagName (Visual Basic .NET)

banner art

Previous Next

IXMLDOMElement.getElementsByTagName (Visual Basic .NET)

The getElementsByTagName method returns a list of all descendant elements that match the supplied name.

Syntax

  IXMLDOMNodeList = IXMLDOMElement
  .getElementsByTagName(
  strtagName As String
)

Parameters

strtagName

[in] String specifying the name of the element to find. The string "*" matches all descendant elements of this element.

Return Values

Returns an IXMLDOMNodeList object containing all elements that match the supplied name.

Remarks

Elements appear in the order encountered in a preorder traversal of this element's tree.

The IXMLDOMNodeList object is returned even if there are no matches. In this case, the length of the list will be set to zero.

The IXMLDOMNodeList is live and immediately reflects changes to the nodes that appear in the list.

Example Code

The following example creates an IXMLDOMNodeList object by using the IXMLDOMElement.getElementsByTagName method, and then displays all of the elements with the desired tag name.

Imports interop_msxml
Imports Microsoft.WindowsMediaServices.Interop

On Error GoTo Err

' Declare variables.
Dim Server As New WMSServerClass()
Dim Playlist As IXMLDOMDocument
Dim Elem As IXMLDOMElement
Dim nodelistMedia As IXMLDOMNodeList
Dim i As Integer

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

' Load a playlist.
Playlist.Load ("file://c:\wmpub\wmroot\simple.wsx")

Elem = Playlist.documentElement
nodelistMedia = Elem.getElementsByTagName("media")

' Iterate through the node list and display 
' the node value of every attribute
' for every node in the list.
For i = 0 To (nodelistMedia.length - 1)
  MsgBox (nodelistMedia.Item(i).Attributes.Item(0).nodeValue)
Next
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