IXMLDOMDocument.createElement (Visual Basic .NET)

banner art

Previous Next

IXMLDOMDocument.createElement (Visual Basic .NET)

The createElement method creates an element node using the specified name.

Syntax

  IXMLDOMElement = IXMLDOMDocument
  .createElement(
  strtagName As String
)

Parameters

strtagName

[in] String specifying the name for the new element node. The name is case-sensitive. This name is subsequently available as the element node's nodeName property.

Return Values

Returns the IXMLDOMElement object for the new element.

Remarks

Creating an element with this method is the same as using createNode where the type parameter value is NODE_ELEMENT and no namespace is specified.

To add the new object, you must explicitly call one of the node insert methods, insertBefore, replaceChild, or appendChild.

The nodeType property has the value NODE_ELEMENT.

Example Code

The following example creates an element called "media" and appends it to the root element.

Imports interop_msxml
Imports Microsoft.WindowsMediaServices.Interop

On Error GoTo Err

' Declare variables.
Dim Server As New WMSServerClass()
Dim Playlist As IXMLDOMDocument
Dim root As IXMLDOMElement
Dim newElem As IXMLDOMElement

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

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

' Retrieve the root element.
Set root = Playlist.documentElement

' Create a new element and append it to the root element.
Set newElem = Playlist.createElement("media")
root.childNodes.Item(1).appendChild newElem
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