IXMLDOMDocument.getElementsByTagName (Visual Basic .NET)

banner art

Previous Next

IXMLDOMDocument.getElementsByTagName (Visual Basic .NET)

The getElementsByTagName method returns a collection of elements that have the specified name.

Syntax

  IXMLDOMNodeList = IXMLDOMDocument
  .getElementsByTagName(
  strtagName As String
)

Parameters

strtagName

[in] String specifying the element name to find. The string "*" returns all elements in the document.

Return Values

Returns a collection of elements that match the specified name.

Remarks

The elements in the collection are returned in the order in which they would be encountered in a preorder traversal of the document tree. In a preorder traversal, the parent root node is visited first and each child node from left to right is then traversed.

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

Example Code

The following example creates an IXMLDOMNodeList object using the IXMLDOMDocument.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 objNodeList As IXMLDOMNodeList

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

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

' Retrieve a list of nodes that matches the query.
Set objNodeList = Playlist.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 (objNodeList.length - 1)
  MsgBox (objNodeList.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