IXMLDOMDocument.createNode (C#)

banner art

Previous Next

IXMLDOMDocument.createNode (C#)

The createNode method creates a node using the supplied type, name, and namespace.

Syntax

  IXMLDOMNode = IXMLDOMDocument
  .createNode(
  object varType,
 string strName,
 string strNamespaceURI
);

Parameters

varType

[in] object with a value that uniquely identifies the node type. This can be specified using either the integer value or the string value.

strName

[in] string containing the value for the new node's nodeName property. The relationship between the node name and node type is summarized below.

strNamespaceURI

[in] string defining the namespace Uniform Resource Identifier (URI). It does not matter what value is assigned to this string because the Windows Media Services SDK implementation of the XML DOM does not fully support namespaces.

Return Values

Returns the newly created node.

Remarks

The strName parameter depends on the value of the varType parameter as shown in the following table. For example, if the node type of the varType parameter is NODE_ELEMENT, the strName parameter will be the node name of the element node.

varType parameter strName parameter
NODE_COMMENT
NODE_TEXT
The nodeName property for this node type is a constant value; the strName parameter is ignored.
NODE_ELEMENT The name of the XML element tag, with any namespace prefix included if present.
NODE_PROCESSING_INSTRUCTION The target (the first token following the <? characters).

You cannot create a node of type NODE_ATTRIBUTE, NODE_DOCUMENT, NODE_DOCUMENT_TYPE, NODE_ENTITY, or NODE_NOTATION.

This method is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

Example Code

The following example creates an element node called "media" and adds it to the child elements for the IXMLDOMDocument object.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;
// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMElement Root;
IXMLDOMNode newNode;

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 node and append it as a child node of 
    // the root element.
    newNode = Playlist.createNode(DOMNodeType.NODE_ELEMENT, "media", "");
    Root.appendChild(newNode);

}
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