IXMLDOMDocument.createElement (C#)
Previous | Next |
IXMLDOMDocument.createElement (C#)
The createElement method creates an element node using the specified name.
Syntax
IXMLDOMElement = IXMLDOMDocument .createElement( string strtagName );
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.
using Microsoft.WindowsMediaServices.Interop; using interop_msxml; // Declare variables. WMSServer Server; IXMLDOMDocument Playlist; IXMLDOMElement Root; IXMLDOMElement newElem; try { // Create a new WMSServer object. Server = new WMSServerClass(); // Create a new playlist object. Playlist = Server.CreatePlaylist(); // Load a playlist. Playlist.load("file://c:\\wmpub\\wmroot\\simple.wsx"); // Retrieve the root element. Root = Playlist.documentElement; // Create a new element and append it to the root element. newElem = Playlist.createElement("media"); Root.childNodes[1].appendChild(newElem); } catch (Exception e) { // TODO: Handle exceptions. }
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 |